You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

build.mjs 1.1KB

1234567891011121314151617181920212223242526272829303132333435363738394041
  1. /* eslint-disable */
  2. import fs from 'fs'
  3. import path from 'path'
  4. import esbuild from 'esbuild'
  5. import { createRequire } from 'module'
  6. const pkg = createRequire(import.meta.url)('../package.json')
  7. async function main() {
  8. try {
  9. esbuild.buildSync({
  10. entryPoints: ['./src/index.tsx'],
  11. outfile: 'dist/index.js',
  12. minify: false,
  13. bundle: true,
  14. format: 'cjs',
  15. target: 'es6',
  16. jsxFactory: 'React.createElement',
  17. jsxFragment: 'React.Fragment',
  18. tsconfig: './tsconfig.json',
  19. define: {
  20. 'process.env.NODE_ENV': '"production"',
  21. 'process.env.LIVEBLOCKS_PUBLIC_API_KEY': `"${process.env.LIVEBLOCKS_PUBLIC_API_KEY}"`,
  22. },
  23. metafile: false,
  24. sourcemap: false,
  25. })
  26. fs.readdirSync('./src/public').forEach((file) =>
  27. fs.copyFile(path.join('./src/public', file), path.join('./dist', file), (err) => {
  28. if (err) throw err
  29. })
  30. )
  31. console.log(`✔ ${pkg.name}: Build completed.`)
  32. } catch (e) {
  33. console.log(`× ${pkg.name}: Build failed due to an error.`)
  34. console.log(e)
  35. }
  36. }
  37. main()