-
Notifications
You must be signed in to change notification settings - Fork 8
Expand file tree
/
Copy pathesbuild.js
More file actions
42 lines (38 loc) · 762 Bytes
/
esbuild.js
File metadata and controls
42 lines (38 loc) · 762 Bytes
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
const esbuild = require('esbuild');
const { sassPlugin } = require('esbuild-sass-plugin');
const [env, ...entryPoints] = process.argv.slice(2);
const baseConfig = {
entryPoints,
bundle: true,
outdir: 'app/assets/builds',
publicPath: 'assets',
assetNames: '[name]-[hash].digested',
logLevel: 'info',
plugins: [
sassPlugin(),
],
loader: {
'.js': 'jsx',
'.png': 'file',
'.woff': 'file',
'.woff2': 'file',
'.eot': 'file',
'.ttf': 'file',
'.svg': 'file',
'.jpg': 'file',
'.lazy.json': 'file',
},
};
if (env === 'dev') {
esbuild.build({
...baseConfig,
sourcemap: 'inline',
watch: true,
});
} else {
esbuild.build({
...baseConfig,
sourcemap: 'external',
minify: true
});
}