fix: ensure docker image configurations can be overriden from
[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 const isDevelopmentBuild = env.BUILD === 'development'
10 const sourcemap = !!isDevelopmentBuild
11 console.info(chalk.green(`Building in ${isDevelopmentBuild ? 'development' : 'production'} mode`))
12 console.time('Build time')
13 await build({
14 entryPoints: ['./src/start.ts', './src/charging-station/ChargingStationWorker.ts'],
15 bundle: true,
16 platform: 'node',
17 format: 'esm',
18 external: [
19 '@mikro-orm/*',
20 'ajv',
21 'ajv-formats',
22 'basic-ftp',
23 'chalk',
24 'date-fns',
25 'http-status-codes',
26 'logform',
27 'mnemonist',
28 'mongodb',
29 'node:*',
30 'poolifier',
31 'rambda',
32 'tar',
33 'winston',
34 'winston/*',
35 'winston-daily-rotate-file',
36 'ws'
37 ],
38 minify: true,
39 sourcemap,
40 entryNames: '[name]',
41 outdir: './dist',
42 plugins: [
43 clean({
44 patterns: [
45 './dist/*',
46 '!./dist/assets',
47 './dist/assets/*.json',
48 './dist/assets/json-schemas',
49 './dist/assets/station-templates',
50 './dist/assets/ui-protocol',
51 './dist/assets/configs-docker'
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 from: ['./src/assets/configs-docker/*.json'],
74 to: ['./assets/configs-docker']
75 }
76 ]
77 })
78 ]
79 })
80 console.timeEnd('Build time')