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 861B

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