2021-11-05 20:31:20 +00:00
|
|
|
|
/* eslint-disable */
|
|
|
|
|
import fs from 'fs'
|
2021-11-11 11:37:57 +00:00
|
|
|
|
import path from 'path'
|
2021-11-05 20:31:20 +00:00
|
|
|
|
import esbuild from 'esbuild'
|
|
|
|
|
import { createRequire } from 'module'
|
|
|
|
|
|
|
|
|
|
const pkg = createRequire(import.meta.url)('../package.json')
|
|
|
|
|
|
2021-12-22 00:14:38 +00:00
|
|
|
|
const { log: jslog } = console
|
|
|
|
|
|
2021-11-05 20:31:20 +00:00
|
|
|
|
async function main() {
|
|
|
|
|
try {
|
|
|
|
|
esbuild.buildSync({
|
|
|
|
|
entryPoints: ['./src/index.tsx'],
|
2021-11-05 21:14:12 +00:00
|
|
|
|
outfile: 'dist/index.js',
|
2021-11-06 16:09:38 +00:00
|
|
|
|
minify: false,
|
2021-11-05 20:31:20 +00:00
|
|
|
|
bundle: true,
|
|
|
|
|
format: 'cjs',
|
|
|
|
|
target: 'es6',
|
|
|
|
|
jsxFactory: 'React.createElement',
|
|
|
|
|
jsxFragment: 'React.Fragment',
|
|
|
|
|
tsconfig: './tsconfig.json',
|
|
|
|
|
define: {
|
|
|
|
|
'process.env.NODE_ENV': '"production"',
|
2021-11-11 11:37:57 +00:00
|
|
|
|
'process.env.LIVEBLOCKS_PUBLIC_API_KEY': `"${process.env.LIVEBLOCKS_PUBLIC_API_KEY}"`,
|
2021-11-05 20:31:20 +00:00
|
|
|
|
},
|
|
|
|
|
metafile: false,
|
|
|
|
|
sourcemap: false,
|
|
|
|
|
})
|
|
|
|
|
|
2021-11-11 11:37:57 +00:00
|
|
|
|
fs.readdirSync('./src/public').forEach((file) =>
|
|
|
|
|
fs.copyFile(path.join('./src/public', file), path.join('./dist', file), (err) => {
|
|
|
|
|
if (err) throw err
|
|
|
|
|
})
|
|
|
|
|
)
|
2021-12-22 00:14:38 +00:00
|
|
|
|
jslog(`✔ ${pkg.name}: Build completed.`)
|
2021-11-05 20:31:20 +00:00
|
|
|
|
} catch (e) {
|
2021-12-22 00:14:38 +00:00
|
|
|
|
jslog(`× ${pkg.name}: Build failed due to an error.`)
|
|
|
|
|
jslog(e)
|
2021-11-05 20:31:20 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
main()
|