-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathesbuild.js
More file actions
51 lines (44 loc) · 1.57 KB
/
esbuild.js
File metadata and controls
51 lines (44 loc) · 1.57 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
/*
* SPDX-FileCopyrightText: 2022 Tim Perry <tim@httptoolkit.tech>
* SPDX-License-Identifier: Apache-2.0
*/
const path = require('path');
const fs = require('fs/promises');
const esbuild = require("esbuild");
const { clean } = require('esbuild-plugin-clean');
const { NodeModulesPolyfillPlugin } = require('@esbuild-plugins/node-modules-polyfill');
const { NodeGlobalsPolyfillPlugin } = require('@esbuild-plugins/node-globals-polyfill');
const manifest = require('./public/manifest.json');
const packageJson = require('./package.json');
(async () => {
manifest.version = packageJson.version; // Usually no-op, except during 'npm version'
await fs.writeFile(path.join('.', 'public', 'manifest.json'), JSON.stringify(manifest, null, 4));
const result = await esbuild.build({
entryPoints: [
"./src/background.ts",
"./src/content-script.ts",
"./src/injected-script.ts"
],
bundle: true,
metafile: true,
outdir: "./public/build",
sourcemap: !!process.env.DEV_MODE,
watch: !!process.env.DEV_MODE,
external: ['brotli-wasm'],
plugins: [
NodeModulesPolyfillPlugin(),
NodeGlobalsPolyfillPlugin({
process: true,
buffer: true
}),
clean({
patterns: [
'./public/build/**/*',
'./public/config/**/*',
]
})
]
})
.catch(() => process.exit(1));
console.log(await esbuild.analyzeMetafile(result.metafile));
})();