-
Notifications
You must be signed in to change notification settings - Fork 4
/
esbuild.js
53 lines (45 loc) · 1.24 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
/* eslint-disable */
// https://github.com/eslint/eslint/discussions/15305
import fs from "fs";
import svg from 'esbuild-plugin-svg';
import cpy from "cpy";
import { deleteSync } from "del";
import esbuild from "esbuild";
import pkg from "./package.json" assert { type: "json" };
import manifest from "./src/manifest.json" assert { type: "json" };
// delete old contents of build/ if exists
deleteSync(["build/**"]);
// create build/ if doesn't exist
if (!fs.existsSync("build")) {
fs.mkdirSync("build");
}
esbuild
.build({
entryPoints: [
"./src/background.js",
"./src/content.js",
"./src/Popup/index.jsx",
],
bundle: true,
minify: true,
sourcemap: process.env.NODE_ENV !== "production",
target: ["chrome100"],
outdir: "./build",
plugins: [svg()],
define: {
"process.env.NODE_ENV": `"${process.env.NODE_ENV}"`,
},
})
.catch(() => process.exit(1));
// update manifest file version
manifest.version = pkg.version;
fs.writeFile(
"build/manifest.json",
JSON.stringify(manifest, null, 2),
(err) => {
if (err) throw err;
console.log("manifest.json updated");
}
);
await cpy(["src/*.png"], "build", { flat: true });
await cpy(["src/Popup/popup.html"], "build/Popup/", { flat: true });