2021-11-06 16:49:53 +00:00
|
|
|
/* eslint-disable no-undef */
|
|
|
|
import fs from 'fs'
|
|
|
|
import esbuildServe from 'esbuild-serve'
|
|
|
|
|
2021-12-22 00:14:38 +00:00
|
|
|
const { log: jslog } = console
|
|
|
|
|
2021-11-06 16:49:53 +00:00
|
|
|
async function main() {
|
2021-11-18 13:09:18 +00:00
|
|
|
if (!fs.existsSync('./dist')) {
|
|
|
|
fs.mkdirSync('./dist')
|
2021-11-06 16:49:53 +00:00
|
|
|
}
|
|
|
|
|
2021-11-18 13:09:18 +00:00
|
|
|
fs.copyFile('./src/index.html', './dist/index.html', (err) => {
|
|
|
|
if (err) throw err
|
|
|
|
})
|
|
|
|
|
2021-11-06 16:49:53 +00:00
|
|
|
try {
|
|
|
|
await esbuildServe(
|
|
|
|
{
|
|
|
|
entryPoints: ['src/index.tsx'],
|
2022-05-21 09:23:07 +00:00
|
|
|
outfile: 'dist/index.js',
|
2021-11-06 16:49:53 +00:00
|
|
|
bundle: true,
|
2021-11-18 13:09:18 +00:00
|
|
|
minify: false,
|
|
|
|
sourcemap: true,
|
2021-11-06 16:49:53 +00:00
|
|
|
incremental: true,
|
2021-11-18 13:09:18 +00:00
|
|
|
target: ['chrome58', 'firefox57', 'safari11', 'edge18'],
|
2021-11-06 16:49:53 +00:00
|
|
|
define: {
|
2021-11-18 13:09:18 +00:00
|
|
|
'process.env.NODE_ENV': '"development"',
|
2021-11-06 16:49:53 +00:00
|
|
|
},
|
|
|
|
watch: {
|
|
|
|
onRebuild(err) {
|
2021-12-22 00:14:38 +00:00
|
|
|
err ? error('❌ Failed') : jslog('✅ Updated')
|
2021-11-06 16:49:53 +00:00
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
{
|
2021-11-18 13:09:18 +00:00
|
|
|
port: 5421,
|
2021-11-06 16:49:53 +00:00
|
|
|
root: './dist',
|
|
|
|
live: true,
|
|
|
|
}
|
|
|
|
)
|
|
|
|
} catch (err) {
|
|
|
|
process.exit(1)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
main()
|