-
-
Notifications
You must be signed in to change notification settings - Fork 262
/
build-css.js
34 lines (28 loc) · 856 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
// @ts-check
import fs from "node:fs";
import path from "node:path";
import sass from "sass";
import autoprefixer from "autoprefixer";
import postcss from "postcss";
const scss = fs
.readdirSync("css")
.filter((file) => file.endsWith(".scss") && !/^\_popover/.test(file))
.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);
}