-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathesbuild.js
More file actions
40 lines (35 loc) · 1.01 KB
/
esbuild.js
File metadata and controls
40 lines (35 loc) · 1.01 KB
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
36
37
38
39
40
const esbuild = require("esbuild");
const postCssPlugin = require("@deanc/esbuild-plugin-postcss");
const { sassPlugin, postcssModules } = require("esbuild-sass-plugin");
const path = require("path");
const componentExports = ["./src/components/GradientLegend/GradientLegend.tsx"];
await esbuild
.build({
entryPoints: componentExports,
bundle: true,
splitting: true,
minify: true,
treeShaking: true,
format: "esm",
outdir: "./dist",
external: ["react", "react-dom"],
loader: { ".scss": "css" }, // Handle SCSS files
plugins: [
sassPlugin({
transform: postcssModules({
filter: /\.module\.scss$/,
basedir: __dirname,
localsConvention: "camelCaseOnly",
}),
}), // Process SCSS
postCssPlugin({
plugins: [require("autoprefixer")()],
}),
],
})
.catch(() => process.exit(1));
const fs = require("fs");
const index = fs.readFileSync("./dist/index.css", "utf-8");
fs.rmdirSync("./dist", { recursive: true });
fs.mkdirSync("./dist");
fs.writeFileSync("./dist/index.css", index);