mirror of
https://github.com/carbon-design-system/carbon-components-svelte.git
synced 2025-09-14 18:01:06 +00:00
build(scripts): convert to ESM
This commit is contained in:
parent
9234119d7b
commit
4881ff7ffd
3 changed files with 48 additions and 49 deletions
|
@ -1,35 +1,34 @@
|
|||
const fs = require("node:fs");
|
||||
const path = require("node:path");
|
||||
const sass = require("sass");
|
||||
const autoprefixer = require("autoprefixer");
|
||||
const postcss = require("postcss");
|
||||
// @ts-check
|
||||
import fs from "node:fs";
|
||||
import path from "node:path";
|
||||
import sass from "sass";
|
||||
import autoprefixer from "autoprefixer";
|
||||
import postcss from "postcss";
|
||||
|
||||
(async () => {
|
||||
const scss = fs
|
||||
.readdirSync("css")
|
||||
.filter((file) => file.endsWith(".scss") && !/^\_popover/.test(file))
|
||||
.map((file) => path.parse(file));
|
||||
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`;
|
||||
for (const { name, base } of scss) {
|
||||
const file = `css/${base}`;
|
||||
const outFile = `css/${name}.css`;
|
||||
|
||||
console.log("[build-css]", file, "-->", outFile);
|
||||
console.log("[build-css]", file, "-->", outFile);
|
||||
|
||||
const { css } = sass.renderSync({
|
||||
file,
|
||||
outFile,
|
||||
outputStyle: "compressed",
|
||||
omitSourceMapUrl: true,
|
||||
includePaths: ["node_modules"],
|
||||
});
|
||||
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 });
|
||||
const prefixed = await postcss([
|
||||
autoprefixer({
|
||||
overrideBrowserslist: ["last 1 version", "ie >= 11", "Firefox ESR"],
|
||||
}),
|
||||
]).process(css, { from: undefined });
|
||||
|
||||
fs.writeFileSync(outFile, prefixed.css);
|
||||
}
|
||||
})();
|
||||
fs.writeFileSync(outFile, prefixed.css);
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue