forked from carbon-design-system/carbon-components-svelte
-
Notifications
You must be signed in to change notification settings - Fork 0
/
build-css.js
35 lines (29 loc) · 895 Bytes
/
build-css.js
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
const fs = require("fs");
const sass = require("sass");
const autoprefixer = require("autoprefixer");
const postcss = require("postcss");
const path = require("path");
(async () => {
const scss = fs
.readdirSync("css")
.filter((file) => file.endsWith(".scss"))
.map((file) => path.parse(file));
for (const { name, base } of scss) {
const file = `css/${base}`;
const outFile = `css/${name}.css`;
console.log("[build-css]", file, "-->", outFile);
const { css } = sass.renderSync({
file,
outFile,
outputStyle: "compressed",
omitSourceMapUrl: true,
includePaths: ["node_modules"],
});
const prefixed = await postcss([
autoprefixer({
overrideBrowserslist: ["last 1 version", "ie >= 11", "Firefox ESR"],
}),
]).process(css, { from: undefined });
fs.writeFileSync(outFile, prefixed.css);
}
})();