-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathesbuild.config.js
51 lines (47 loc) · 1001 Bytes
/
esbuild.config.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
import esbuild from 'esbuild';
import { injectCSSPlugin } from './esbuild/injectCSSPlugin.js';
const baseConfig = {
entryPoints: ['src/index.ts'],
bundle: true,
minify: true,
platform: 'browser',
sourcemap: true,
target: ['es2015'],
loader: {
'.ts': 'ts',
'.svg': 'dataurl',
'.png': 'dataurl',
'.gif': 'dataurl',
},
define: { 'process.env.MODE': '"production"' },
};
// ESM
esbuild
.build({
...baseConfig,
plugins: [injectCSSPlugin('../dist/esm/')],
outdir: 'dist/esm/',
format: 'esm',
splitting: true,
chunkNames: 'chunks/[name]-[hash]',
})
.catch(() => process.exit(1));
// IIFE for <script> tag
esbuild
.build({
...baseConfig,
plugins: [injectCSSPlugin('../dist/iife/')],
outfile: 'dist/iife/index.js',
format: 'iife',
globalName: 'Anyline',
})
.catch(() => process.exit(1));
// CJS
esbuild
.build({
...baseConfig,
plugins: [injectCSSPlugin('../dist/cjs/')],
outfile: 'dist/cjs/index.js',
format: 'cjs',
})
.catch(() => process.exit(1));