mirror of
https://github.com/carbon-design-system/carbon-components-svelte.git
synced 2025-09-18 11:36:36 +00:00
build: convert cjs to esm
This commit is contained in:
parent
0be42a4b66
commit
778c469b6d
2 changed files with 21 additions and 22 deletions
|
@ -1,20 +1,19 @@
|
||||||
const fs = require("fs");
|
import fs from "fs";
|
||||||
const path = require("path");
|
import path from "path";
|
||||||
const glob = require("glob");
|
import glob from "glob";
|
||||||
const pkg = require("../package.json");
|
|
||||||
|
|
||||||
function buildApi() {
|
const pkg = JSON.parse(
|
||||||
const components = {};
|
fs.readFileSync(new URL("../package.json", import.meta.url), "utf8")
|
||||||
|
);
|
||||||
|
|
||||||
glob.sync("src/**/*.svelte").forEach((file) => {
|
const components = {};
|
||||||
|
|
||||||
|
glob.sync("src/**/*.svelte").forEach((file) => {
|
||||||
const { name } = path.parse(file);
|
const { name } = path.parse(file);
|
||||||
components[name] = { path: path.join(pkg.name, file) };
|
components[name] = { path: path.join(pkg.name, file) };
|
||||||
});
|
});
|
||||||
|
|
||||||
fs.writeFileSync(
|
fs.writeFileSync(
|
||||||
"preprocess/api.json",
|
"preprocess/api.json",
|
||||||
JSON.stringify({ version: pkg.version, components }, null, 2)
|
JSON.stringify({ version: pkg.version, components }, null, 2)
|
||||||
);
|
);
|
||||||
}
|
|
||||||
|
|
||||||
buildApi();
|
|
||||||
|
|
|
@ -1,8 +1,8 @@
|
||||||
const fs = require("fs");
|
import fs from "fs";
|
||||||
const sass = require("sass");
|
import sass from "sass";
|
||||||
const autoprefixer = require("autoprefixer");
|
import autoprefixer from "autoprefixer";
|
||||||
const postcss = require("postcss");
|
import postcss from "postcss";
|
||||||
const path = require("path");
|
import path from "path";
|
||||||
|
|
||||||
(async () => {
|
(async () => {
|
||||||
const scss = fs
|
const scss = fs
|
||||||
|
@ -10,7 +10,7 @@ const path = require("path");
|
||||||
.filter((file) => file.endsWith(".scss"))
|
.filter((file) => file.endsWith(".scss"))
|
||||||
.map((file) => path.parse(file));
|
.map((file) => path.parse(file));
|
||||||
|
|
||||||
for (const { name, base } of scss) {
|
for await (const { name, base } of scss) {
|
||||||
const file = `css/${base}`;
|
const file = `css/${base}`;
|
||||||
const outFile = `css/${name}.css`;
|
const outFile = `css/${name}.css`;
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue