-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbuild.mjs
57 lines (50 loc) · 1.13 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
47
48
49
50
51
52
53
54
55
56
import { exec } from "child_process";
import { build } from "esbuild";
import fs from "fs";
let define = {};
for (const k in process.env) {
define[`process.env.${k}`] = JSON.stringify(process.env[k]);
}
///
/// Build index.html (simple find and replace)
///
console.log("### Building index.html");
fs.writeFileSync(
"dist/index.html",
fs
.readFileSync("index.html.in")
.toString()
.split("%PUBLIC_URL%/")
.join(process.env.PUBLIC_URL || "/")
.split("%PUBLIC_URL%")
.join(process.env.PUBLIC_URL || "/")
);
///
/// Build bundle.js (esbuild)
///
console.log("### Building bundle.js");
build({
entryPoints: ["src/index.tsx"],
bundle: true,
platform: "browser",
outfile: "dist/bundle.js",
define,
plugins: [],
logLevel: "info",
sourcemap: "linked",
...(process.env.OXO_MINIFY === "true"
? {
minify: true,
}
: {}),
});
///
/// Build styles.css (tailwind)
///
console.log("### Building styles.css");
exec("tailwind -i ./src/index.css -o ./dist/styles.css");
///
/// Copy files
///
// console.log("### Copying misc files");
// exec("cp ./src/banner.txt ./dist"); // home page banner text