forked from arconnectio/ArConnect
-
Notifications
You must be signed in to change notification settings - Fork 0
/
esbuild.js
53 lines (51 loc) · 1.37 KB
/
esbuild.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
const esbuild = require("esbuild"),
autoprefixer = require("autoprefixer"),
postCssPlugin = require("esbuild-plugin-postcss2"),
{
NodeModulesPolyfillPlugin
} = require("@esbuild-plugins/node-modules-polyfill"),
fs = require("fs"),
{ join } = require("path"),
GlobalsPolyfills = require("@esbuild-plugins/node-globals-polyfill").default;
const outDir = "./public/build";
if (fs.existsSync(join(__dirname, outDir)))
fs.rmSync(join(__dirname, outDir), { recursive: true });
esbuild
.build({
entryPoints: [
"./src/scripts/background.ts",
"./src/scripts/content.ts",
"./src/scripts/injected.ts",
"./src/views/popup.tsx",
"./src/views/auth.tsx",
"./src/views/welcome.tsx",
...(process.env.BUILD_TARGET === "FIREFOX"
? []
: ["./src/views/archive.tsx"])
],
format: "iife",
bundle: true,
minify: true,
sourcemap: true,
watch: process.env.NODE_ENV !== "production",
inject: ["./src/utils/polyfill.js"],
target: ["chrome67", "firefox68"],
outdir: outDir,
define: {
global: "window"
},
loader: {
".png": "dataurl",
".svg": "dataurl"
},
plugins: [
NodeModulesPolyfillPlugin(),
GlobalsPolyfills({
buffer: true
}),
postCssPlugin.default({
plugins: [autoprefixer]
})
]
})
.catch(() => process.exit(1));