-
Notifications
You must be signed in to change notification settings - Fork 1
/
postcss.config.cjs
40 lines (32 loc) · 911 Bytes
/
postcss.config.cjs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
/**
* @typedef {import("postcss").Plugin} Plugin;
* @typedef {import("postcss").AcceptedPlugin} AcceptedPlugin;
*/
const process = require("process");
const postcssCustomMedia = require("postcss-custom-media");
const postcssJitProps = require("postcss-jit-props");
const cssnano = require("cssnano");
const { customMedia, customProperties } = require("./src/theme.cjs");
const { NODE_ENV } = process.env;
console.log({ customMedia, customProperties });
/**
* @param {boolean} isProd
* @returns {AcceptedPlugin[]}
*/
function getPlugins(isProd) {
const plugins = [
postcssCustomMedia({ importFrom: { customMedia } }),
postcssJitProps({
...customMedia,
...customProperties,
files: ["./src/styles/open-props.min.css"],
}),
];
if (isProd) {
plugins.push(cssnano({ preset: "advanced" }));
}
return plugins;
}
module.exports = {
plugins: getPlugins(NODE_ENV === "production"),
};