diff --git a/scripts/build-api.js b/scripts/build-api.js index 90d2d172..63cbe465 100644 --- a/scripts/build-api.js +++ b/scripts/build-api.js @@ -1,20 +1,19 @@ -const fs = require("fs"); -const path = require("path"); -const glob = require("glob"); -const pkg = require("../package.json"); +import fs from "fs"; +import path from "path"; +import glob from "glob"; -function buildApi() { - const components = {}; +const pkg = JSON.parse( + fs.readFileSync(new URL("../package.json", import.meta.url), "utf8") +); - glob.sync("src/**/*.svelte").forEach((file) => { - const { name } = path.parse(file); - components[name] = { path: path.join(pkg.name, file) }; - }); +const components = {}; - fs.writeFileSync( - "preprocess/api.json", - JSON.stringify({ version: pkg.version, components }, null, 2) - ); -} +glob.sync("src/**/*.svelte").forEach((file) => { + const { name } = path.parse(file); + components[name] = { path: path.join(pkg.name, file) }; +}); -buildApi(); +fs.writeFileSync( + "preprocess/api.json", + JSON.stringify({ version: pkg.version, components }, null, 2) +); diff --git a/scripts/build-css.js b/scripts/build-css.js index 378109af..7d722e4e 100644 --- a/scripts/build-css.js +++ b/scripts/build-css.js @@ -1,8 +1,8 @@ -const fs = require("fs"); -const sass = require("sass"); -const autoprefixer = require("autoprefixer"); -const postcss = require("postcss"); -const path = require("path"); +import fs from "fs"; +import sass from "sass"; +import autoprefixer from "autoprefixer"; +import postcss from "postcss"; +import path from "path"; (async () => { const scss = fs @@ -10,7 +10,7 @@ const path = require("path"); .filter((file) => file.endsWith(".scss")) .map((file) => path.parse(file)); - for (const { name, base } of scss) { + for await (const { name, base } of scss) { const file = `css/${base}`; const outFile = `css/${name}.css`;