-
Notifications
You must be signed in to change notification settings - Fork 33
/
build.mjs
executable file
·46 lines (43 loc) · 1.18 KB
/
build.mjs
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
41
42
43
44
45
46
import esbuild from "esbuild";
import dotenv from "dotenv";
import { sassPlugin } from "esbuild-sass-plugin";
import tailwindcss from "tailwindcss";
import autoprefixer from "autoprefixer";
import postcss from "postcss";
import postcssPresetEnv from "postcss-preset-env";
// Load environment variables from .env file
dotenv.config();
// List of environment variables to expose to the build
const env = {
"process.env.XSTATE_INSPECT": JSON.stringify(
process.env.XSTATE_INSPECT || "false",
),
};
esbuild.build({
entryPoints: ["./src/index.tsx"],
bundle: true,
minify: true,
target: ["es2022"],
outdir: "lonboard/static/",
format: "esm",
// Ref https://github.com/manzt/anywidget/issues/369#issuecomment-1792376003
define: {
"define.amd": "false",
...env,
},
plugins: [
sassPlugin({
async transform(source) {
const { css } = await postcss([
tailwindcss,
autoprefixer,
postcssPresetEnv({ stage: 0 }),
]).process(source, { from: undefined });
return css;
},
}),
],
// Code splitting didn't work initially because it tried to load from a local
// relative path ./chunk.js
// splitting: true,
});