-
-
Notifications
You must be signed in to change notification settings - Fork 9
/
build.js
37 lines (34 loc) · 928 Bytes
/
build.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
35
36
37
let StyleLoader = {
name: "inline-style",
setup({ onLoad }) {
let fs = require("fs");
onLoad({ filter: /\.css$/ }, async (args) => {
let css = await fs.promises.readFile(args.path, "utf8");
return { contents: css, loader: "text" };
});
},
};
let SVGLoader = {
name: "svg",
setup({ onLoad }) {
let fs = require("fs");
onLoad({ filter: /\.svg$/ }, async (args) => {
let svg = await fs.promises.readFile(args.path, "utf8");
return { contents: svg, loader: "text" };
});
},
};
const { polyfillNode } = require("esbuild-plugin-polyfill-node");
(async () => {
await require("esbuild")
.build({
plugins: [polyfillNode(), StyleLoader, SVGLoader],
entryPoints: ["./src/lib/web.ts"],
bundle: true,
target: "ES2020",
outfile: "./dist/index.min.js",
sourcemap: true,
minify: true,
})
.catch(() => process.exit(1));
})();