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