-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathesbuild-entries.js
More file actions
56 lines (45 loc) · 1.16 KB
/
esbuild-entries.js
File metadata and controls
56 lines (45 loc) · 1.16 KB
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
// For transpiling all "/**/*.entry.{js,jsx}" files
// for react pages mainly
import esbuild from "esbuild";
import fs from "fs";
import path from "path";
import { sassPlugin } from "esbuild-sass-plugin";
import utils from "./libs/utils.js";
const log = (...args) => console.log("esbuild-entries.js:", ...args);
const root = path.dirname("");
const app = path.resolve(root, "pages");
utils.setup({
js: {
entries: [app],
},
});
const entryPoints = await utils.entries();
log("entryPoints", entryPoints);
const watch = process.argv.includes("--watch");
let ctx = await esbuild[watch ? "context" : "build"]({
entryPoints,
outdir: "dist",
bundle: true,
minify: false,
sourcemap: true,
target: "esnext",
plugins: [sassPlugin()],
loader: {
".js": "jsx",
".jsx": "jsx",
".scss": "css",
},
define: {
"process.env.NODE_ENV": JSON.stringify("production"),
},
entryNames: "[name].bundle",
jsxFactory: "React.createElement",
jsxFragment: "React.Fragment",
});
log("exbuilddone2");
if (watch) {
log(`watch mode: ${watch}`, ctx);
ctx.watch(); //https://esbuild.github.io/api/#serve-proxy
} else {
log(`no watch mode: ${watch}`, ctx);
}