-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy path.esbuild.config.js
61 lines (56 loc) · 1.33 KB
/
.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
52
53
54
55
56
57
58
59
60
61
const esbuild = require('esbuild')
const sassPlugin = require('esbuild-sass-plugin').sassPlugin
const watch = process.argv.includes('--watch')
const minify = !watch
const replaceNodeBuiltIns = () => {
const replace = {
path: require.resolve('path-browserify'),
}
const filter = RegExp(`^(${Object.keys(replace).join('|')})$`)
return {
name: 'replaceNodeBuiltIns',
setup(build) {
build.onResolve({ filter }, (arg) => ({
path: replace[arg.path],
}))
},
}
}
esbuild
.build({
entryPoints: ['src/extension.ts'],
tsconfig: './tsconfig.json',
bundle: true,
external: ['vscode'],
sourcemap: watch,
minify,
watch,
platform: 'node',
outfile: 'dist/extension.js',
})
.catch(() => process.exit(1))
esbuild
.build({
entryPoints: ['media/editor/index.ts'],
tsconfig: './tsconfig.json',
bundle: true,
external: ['vscode'],
sourcemap: watch ? 'inline' : false,
minify,
watch,
plugins: [replaceNodeBuiltIns()],
mainFields: ['browser', 'module', 'main'],
platform: 'browser',
outfile: 'dist/editor.js',
})
.catch(() => process.exit(1))
esbuild
.build({
entryPoints: ['media/editor/style.scss'],
bundle: true,
minify,
plugins: [sassPlugin()],
watch,
outfile: 'dist/editor.css',
})
.catch(() => process.exit(1))