No Description

bundle.js 1.9KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182
  1. /* eslint-disable n/no-unpublished-import */
  2. import chalk from 'chalk'
  3. import { build } from 'esbuild'
  4. import { clean } from 'esbuild-plugin-clean'
  5. import { copy } from 'esbuild-plugin-copy'
  6. import { env } from 'node:process'
  7. const isDevelopmentBuild = env.BUILD === 'development'
  8. const sourcemap = !!isDevelopmentBuild
  9. console.info(chalk.green(`Building in ${isDevelopmentBuild ? 'development' : 'production'} mode`))
  10. console.time('Build time')
  11. await build({
  12. bundle: true,
  13. entryNames: '[name]',
  14. entryPoints: ['./src/start.ts', './src/charging-station/ChargingStationWorker.ts'],
  15. external: [
  16. '@mikro-orm/*',
  17. 'ajv',
  18. 'ajv-formats',
  19. 'basic-ftp',
  20. 'chalk',
  21. 'date-fns',
  22. 'date-fns/*',
  23. 'http-status-codes',
  24. 'logform',
  25. 'mnemonist',
  26. 'mongodb',
  27. 'node:*',
  28. 'poolifier',
  29. 'rambda',
  30. 'tar',
  31. 'winston',
  32. 'winston/*',
  33. 'winston-daily-rotate-file',
  34. 'ws',
  35. ],
  36. format: 'esm',
  37. minify: true,
  38. outdir: './dist',
  39. platform: 'node',
  40. plugins: [
  41. clean({
  42. patterns: [
  43. './dist/*',
  44. '!./dist/assets',
  45. './dist/assets/*.json',
  46. './dist/assets/json-schemas',
  47. './dist/assets/station-templates',
  48. './dist/assets/ui-protocol',
  49. './dist/assets/configs-docker',
  50. ],
  51. }),
  52. copy({
  53. assets: [
  54. {
  55. from: ['./src/assets/config.json'],
  56. to: ['./assets'],
  57. },
  58. {
  59. from: ['./src/assets/idtags!(-template)*.json'],
  60. to: ['./assets'],
  61. },
  62. {
  63. from: ['./src/assets/json-schemas/**/*.json'],
  64. to: ['./assets/json-schemas'],
  65. },
  66. {
  67. from: ['./src/assets/station-templates/**/*.json'],
  68. to: ['./assets/station-templates'],
  69. },
  70. {
  71. from: ['./src/assets/configs-docker/*.json'],
  72. to: ['./assets/configs-docker'],
  73. },
  74. ],
  75. }),
  76. ],
  77. sourcemap,
  78. treeShaking: true,
  79. })
  80. console.timeEnd('Build time')