-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbuild.js
53 lines (49 loc) · 1.45 KB
/
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
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
import esbuild from "esbuild";
import extensibilityMap from "@neos-project/neos-ui-extensibility/extensibilityMap.json" with { type: "json" };
import stylexPlugin from "@stylexjs/esbuild-plugin";
import path from "path";
import { fileURLToPath } from "url";
const __dirname = path.dirname(fileURLToPath(import.meta.url));
const watch = process.argv.includes("--watch");
const dev = process.argv.includes("--dev");
const minify = !dev && !watch;
/** @type {import("esbuild").BuildOptions} */
const options = {
logLevel: "info",
bundle: true,
minify,
sourcemap: watch,
target: "es2020",
legalComments: "none",
entryPoints: ["Resources/Private/Editor/*.js"],
outdir: "Resources/Public",
alias: extensibilityMap,
format: "esm",
splitting: true,
loader: {
".js": "jsx",
},
plugins: [
stylexPlugin({
classNamePrefix: "editorstyling-",
useCSSLayers: false,
dev: false,
generatedCSSFileName: path.resolve(__dirname, "Resources/Public/Editor.css"),
stylexImports: ["@stylexjs/stylex"],
unstable_moduleResolution: {
type: "commonJS",
rootDir: __dirname,
},
}),
],
};
if (minify) {
options.drop = ["debugger"];
options.pure = ["console.log"];
options.dropLabels = ["DEV"];
}
if (watch) {
esbuild.context(options).then((ctx) => ctx.watch());
} else {
esbuild.build(options);
}