Skip to content

Commit 4566499

Browse files
committed
fix(#81): remove PostCSS from core dependencies
1 parent f8c20ca commit 4566499

File tree

3 files changed

+21
-5
lines changed

3 files changed

+21
-5
lines changed

.changeset/late-lions-leave.md

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"microsite": patch
3+
---
4+
5+
Remove PostCSS logic from core dependencies. Microsite will prompt users to install PostCSS locally if detected.

packages/microsite/package.json

-5
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,6 @@
4545
"dependencies": {
4646
"@prefresh/snowpack": "^3.0.1",
4747
"@snowpack/plugin-dotenv": "^2.0.5",
48-
"@snowpack/plugin-postcss": "^1.0.11",
4948
"arg": "^5.0.0",
5049
"cacache": "^15.0.5",
5150
"cosmiconfig": "^7.0.0",
@@ -58,10 +57,6 @@
5857
"open": "^7.3.0",
5958
"path-browserify": "^1.0.1",
6059
"polka": "^0.5.2",
61-
"postcss": "^8.2.1",
62-
"postcss-cli": "^8.3.1",
63-
"postcss-flexbugs-fixes": "^5.0.2",
64-
"postcss-preset-env": "^6.7.0",
6560
"preact": "^10.5.5",
6661
"preact-render-to-string": "5.1.11",
6762
"prettier": "^2.1.2",

packages/microsite/src/utils/command.ts

+16
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ const require = createRequire(import.meta.url);
66
import { fileExists } from "./fs.js";
77
import { createConfiguration } from "snowpack";
88
import cc from "cosmiconfig";
9+
import { yellow } from "kleur/colors";
910
const { cosmiconfig } = cc;
1011
const _config = require("microsite/assets/snowpack.config.cjs");
1112

@@ -40,6 +41,21 @@ export async function loadConfiguration(mode: "dev" | "build") {
4041
: {};
4142
const userConfig = snowpackconfigPath ? require(snowpackconfigPath) : {};
4243

44+
if (usesPostCSS) {
45+
const missing = [];
46+
const deps = ['@snowpack/plugin-postcss', 'postcss', 'postcss-cli'];
47+
deps.forEach(dependency => {
48+
try {
49+
require.resolve(dependency);
50+
} catch (e) {
51+
missing.push(dependency);
52+
}
53+
});
54+
if (missing.length > 0) {
55+
console.error(yellow(`It looks like you're trying to use PostCSS!\nMicrosite will automatically use your configuration, but requires some 'devDependencies' to do so.\n\nPlease run 'npm install --save-dev ${missing.join(' ')}'\n`));
56+
process.exit(1);
57+
}
58+
}
4359
const additionalPlugins = usesPostCSS ? ["@snowpack/plugin-postcss"] : [];
4460

4561
switch (mode) {

0 commit comments

Comments
 (0)