-
Notifications
You must be signed in to change notification settings - Fork 3
/
build.js
42 lines (39 loc) · 1.13 KB
/
build.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
const path = require('path')
const { build, analyzeMetafile } = require('esbuild')
const alias = require('esbuild-plugin-alias')
const { wrapWithQuotes } = require('./buildUtils')
async function buildWorker() {
try {
const result = await build({
bundle: true,
sourcemap: true,
metafile: true,
// Uncomment to reduce bundle size
// minify: true,
treeShaking: true,
format: 'esm',
target: 'esnext',
entryPoints: [path.join(__dirname, '../src', 'index.ts')],
outdir: path.join(__dirname, '../dist'),
outExtension: { '.js': '.mjs' },
define: {
ENVIRONMENT: wrapWithQuotes(process.env.ENVIRONMENT || 'development'),
},
plugins: [
alias({
'@prisma/client': require.resolve('@prisma/client'),
}),
],
inject: ['./polyfills.js'],
})
// Uncomment to see what takes up space in the bundle
// const bundleSizeAnalysis = await analyzeMetafile(result.metafile, {
// color: true,
// })
// console.log(bundleSizeAnalysis)
} catch (err) {
console.error(err)
process.exitCode = 1
}
}
buildWorker()