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.

dev.mjs 907B

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  1. /* eslint-disable no-undef */
  2. import fs from 'fs'
  3. import esbuildServe from 'esbuild-serve'
  4. async function main() {
  5. if (!fs.existsSync('./dist')) {
  6. fs.mkdirSync('./dist')
  7. }
  8. fs.copyFile('./src/index.html', './dist/index.html', (err) => {
  9. if (err) throw err
  10. })
  11. try {
  12. await esbuildServe(
  13. {
  14. entryPoints: ['src/index.tsx'],
  15. outfile: 'dist/index.js',
  16. bundle: true,
  17. minify: false,
  18. sourcemap: true,
  19. incremental: true,
  20. target: ['chrome58', 'firefox57', 'safari11', 'edge18'],
  21. define: {
  22. 'process.env.NODE_ENV': '"development"',
  23. },
  24. watch: {
  25. onRebuild(err) {
  26. err ? error('❌ Failed') : log('✅ Updated')
  27. },
  28. },
  29. },
  30. {
  31. port: 5420,
  32. root: './dist',
  33. live: true,
  34. }
  35. )
  36. } catch (err) {
  37. process.exit(1)
  38. }
  39. }
  40. main()