tldraw/examples/tldraw-example/scripts/build.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

41 lines
1.1 KiB
JavaScript
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

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