tldraw/examples/core-example/scripts/dev.mjs
Steve Ruiz e6a3e5c3ea
[big chore] restore core to monorepo (#287)
* move core into repo, apps into apps folder, update tests

* Update scripts for build:core

* improve scripts

* remove noise from www

* Update .gitignore

* Fix focus bug

* add ci test script

* Update main.yml
2021-11-18 13:09:18 +00:00

44 lines
908 B
JavaScript

/* eslint-disable no-undef */
import fs from 'fs'
import esbuildServe from 'esbuild-serve'
async function main() {
if (!fs.existsSync('./dist')) {
fs.mkdirSync('./dist')
}
fs.copyFile('./src/index.html', './dist/index.html', (err) => {
if (err) throw err
})
try {
await esbuildServe(
{
entryPoints: ['src/index.tsx'],
outfile: 'dist/bundle.js',
bundle: true,
minify: false,
sourcemap: true,
incremental: true,
target: ['chrome58', 'firefox57', 'safari11', 'edge18'],
define: {
'process.env.NODE_ENV': '"development"',
},
watch: {
onRebuild(err) {
err ? error('❌ Failed') : log('✅ Updated')
},
},
},
{
port: 5421,
root: './dist',
live: true,
}
)
} catch (err) {
process.exit(1)
}
}
main()