-
Notifications
You must be signed in to change notification settings - Fork 3.8k
/
esbuild.dev.mjs
33 lines (31 loc) · 939 Bytes
/
esbuild.dev.mjs
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
import * as esbuild from 'esbuild';
// Fetch 'RELATIVE_URL_ROOT' ENV variable value while removing any trailing slashes.
const relativeUrlRoot = (process.env.RELATIVE_URL_ROOT || '').replace(/\/*$/, '');
esbuild.context({
entryPoints: ['app/javascript/main.jsx'],
bundle: true,
sourcemap: true,
outdir: 'app/assets/builds',
loader: {
'.png': 'dataurl',
'.svg': 'text',
},
define: {
'process.env.RELATIVE_URL_ROOT': `"${relativeUrlRoot}"`,
'process.env.OMNIAUTH_PATH': `"${relativeUrlRoot}/auth/openid_connect"`, // currently, only OIDC is implemented
},
}).then(context => {
if (process.argv.includes("--watch")) {
// Enable watch mode
context.watch()
} else {
// Build once and exit if not in watch mode
context.rebuild().then(result => {
context.dispose()
})
}
console.log('build succeeded');
}).catch((e) => {
console.error('build failed:', e);
process.exit(1)
})