-
Notifications
You must be signed in to change notification settings - Fork 1
/
esbuild.js
61 lines (58 loc) · 1.47 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
54
55
56
57
58
59
60
61
const stylePlugin = require('esbuild-style-plugin');
const args = process.argv.slice(2);
const PROD = args.includes('--prod');
require('esbuild')
.build({
entryPoints: [
'src/assets/logo-blue-1024.png',
'src/main.tsx',
'src/background.ts',
'src/contentScript.ts',
'src/injectedScript.ts',
'src/confirmation.html',
'popup.html',
'manifest.json',
],
outdir: 'dist',
bundle: true,
platform: 'browser',
sourcemap: !PROD,
watch: !PROD,
minify: PROD,
treeShaking: PROD,
format: 'esm',
external: ['~@vite/vitejs-utils'],
loader: {
'.html': 'copy',
'.json': 'copy',
'.png': 'copy',
},
drop: PROD ? ['console'] : [],
// logLevel: 'debug',
// logLevel: 'silent',
plugins: [
stylePlugin({
postcss: {
plugins: [
// require('tailwindcss'), require('autoprefixer')
// https://github.com/g45t345rt/esbuild-style-plugin/issues/3#issuecomment-1044801403
// require('postcss-import')({
// path: [path.join(__dirname, 'assets/css'), path.join(__dirname, 'assets')],
// }),
// require('postcss-url')({ url: 'inline' }),
require('postcss-nested'),
require('autoprefixer'),
require('tailwindcss')(),
],
},
}),
],
watch: !PROD && {
onRebuild(error, result) {
const time = Date.now();
if (error) console.error(`watch build failed ${time}:`, error);
else console.log(`watch build succeeded ${time}:`, result);
},
},
})
.catch(() => process.exit(1));