2021-11-05 20:31:20 +00:00
|
|
|
/* eslint-disable no-undef */
|
|
|
|
import fs from 'fs'
|
|
|
|
import esbuildServe from 'esbuild-serve'
|
2021-11-08 14:21:37 +00:00
|
|
|
import dotenv from 'dotenv'
|
|
|
|
|
|
|
|
dotenv.config()
|
2021-11-05 20:31:20 +00:00
|
|
|
|
|
|
|
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'],
|
2021-11-05 21:14:12 +00:00
|
|
|
outfile: 'dist/index.js',
|
2021-11-05 20:31:20 +00:00
|
|
|
minify: false,
|
2021-11-06 16:09:38 +00:00
|
|
|
bundle: true,
|
2021-11-05 20:31:20 +00:00
|
|
|
sourcemap: true,
|
|
|
|
incremental: true,
|
2021-11-08 14:21:37 +00:00
|
|
|
format: 'cjs',
|
|
|
|
target: 'es6',
|
2021-11-05 20:31:20 +00:00
|
|
|
define: {
|
|
|
|
'process.env.NODE_ENV': '"development"',
|
2021-11-08 14:21:37 +00:00
|
|
|
'process.env.LIVEBLOCKS_PUBLIC_API_KEY': `"${process.env.LIVEBLOCKS_PUBLIC_API_KEY}"`,
|
2021-11-05 20:31:20 +00:00
|
|
|
},
|
|
|
|
watch: {
|
|
|
|
onRebuild(err) {
|
|
|
|
err ? error('❌ Failed') : log('✅ Updated')
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
{
|
2021-11-07 14:29:24 +00:00
|
|
|
port: 5420,
|
2021-11-05 20:31:20 +00:00
|
|
|
root: './dist',
|
|
|
|
live: true,
|
|
|
|
}
|
|
|
|
)
|
|
|
|
} catch (err) {
|
|
|
|
process.exit(1)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
main()
|