tldraw/packages/dev/esbuild.config.mjs
2021-08-10 18:19:30 +01:00

34 lines
773 B
JavaScript

/* eslint-disable no-undef */
import esbuild from 'esbuild'
import serve, { error, log } from 'create-serve'
const isDevServer = process.argv.includes('--dev')
esbuild
.build({
entryPoints: ['src/index.tsx'],
bundle: true,
outfile: 'dist/bundle.js',
minify: false,
sourcemap: true,
incremental: isDevServer,
target: ['chrome58', 'firefox57', 'safari11', 'edge18'],
define: {
'process.env.NODE_ENV': isDevServer ? '"development"' : '"production"',
},
watch: isDevServer && {
onRebuild(err) {
serve.update()
err ? error('❌ Failed') : log('✅ Updated')
},
},
})
.catch(() => process.exit(1))
if (isDevServer) {
serve.start({
port: 5000,
root: './dist',
live: true,
})
}