tldraw/dev/esbuild.config.mjs
Steve Ruiz b68a4681e1
[improvement] repo shuffle (#214)
* move folders out of packages

* Remove custom yarn stuff, remove duplicate readme

* Remove stitches config

* Add README script.

* bump deps

* Fix script

* Update package.json
2021-11-02 11:46:25 +00:00

44 lines
1,002 B
JavaScript

/* eslint-disable no-undef */
import fs from 'fs'
import esbuild from 'esbuild'
import serve, { error, log } from 'create-serve'
const isDevServer = true
if (!fs.existsSync('./dist')) {
fs.mkdirSync('./dist')
}
fs.copyFile('./src/index.html', './dist/index.html', (err) => {
if (err) throw err
})
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.LIVEBLOCKS_PUBLIC_API_KEY': process.env.LIVEBLOCKS_PUBLIC_API_KEY,
'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,
})
}