-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbuild.mts
39 lines (34 loc) · 1.02 KB
/
build.mts
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
import { env } from 'node:process';
if (env.OUT_DIR === undefined) {
console.error("OUT_DIR is not defined; don't run this npm command manually, do it from `cargo build` instead.");
process.exit(1);
}
import * as esbuild from 'esbuild'
import { createRequire } from "node:module";
import { html } from "@esbuilder/html";
import stylePlugin from "esbuild-style-plugin";
const require = createRequire(import.meta.url);
const prompt = "Building web frontend...";
console.time(prompt);
await esbuild.build({
entryPoints: ['assets/index.html', 'assets/app.tsx'],
bundle: true,
// cargo defines OUT_DIR to be where the build artifacts are place
outdir: env.OUT_DIR,
assetNames: "[name]",
sourcemap: true,
plugins: [
html({
entryNames: "[name]",
assetNames: "[name]",
}),
stylePlugin({
postcss: {
plugins: [
require("postcss-import"),
],
}
}),
],
});
console.timeEnd(prompt);