build(deps-dev): Bump jsdom from 23.0.1 to 23.1.0 in /ui/web
[e-mobility-charging-stations-simulator.git] / bundle.js
CommitLineData
44ebef4c 1/* eslint-disable n/no-unpublished-import */
66a7748d 2import { env } from 'node:process'
44ebef4c 3
66a7748d
JB
4import chalk from 'chalk'
5import { build } from 'esbuild'
6import { clean } from 'esbuild-plugin-clean'
7import { copy } from 'esbuild-plugin-copy'
3dfc5d50 8
66a7748d 9;(async () => {
a7c99243
JB
10 const isDevelopmentBuild = env.BUILD === 'development'
11 const sourcemap = !!isDevelopmentBuild
66a7748d
JB
12 console.info(chalk.green(`Building in ${isDevelopmentBuild ? 'development' : 'production'} mode`))
13 console.time('Build time')
44ebef4c
JB
14 await build({
15 entryPoints: ['./src/start.ts', './src/charging-station/ChargingStationWorker.ts'],
16 bundle: true,
17 platform: 'node',
18 format: 'esm',
ae2f5292
JB
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',
a7d26b50 29 // 'mnemonist',
ae2f5292
JB
30 'mongodb',
31 'node:*',
32 'poolifier',
33 'tar',
34 'winston',
ab34592f 35 'winston/*',
ae2f5292 36 'winston-daily-rotate-file',
66a7748d 37 'ws'
ae2f5292 38 ],
44ebef4c
JB
39 minify: true,
40 sourcemap,
4eeee49c 41 entryNames: '[name]',
44ebef4c
JB
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',
66a7748d
JB
51 './dist/assets/ui-protocol'
52 ]
44ebef4c
JB
53 }),
54 copy({
55 assets: [
56 {
57 from: ['./src/assets/config.json'],
66a7748d 58 to: ['./assets']
44ebef4c
JB
59 },
60 {
61 from: ['./src/assets/idtags!(-template)*.json'],
66a7748d 62 to: ['./assets']
44ebef4c
JB
63 },
64 {
65 from: ['./src/assets/json-schemas/**/*.json'],
66a7748d 66 to: ['./assets/json-schemas']
44ebef4c
JB
67 },
68 {
69 from: ['./src/assets/station-templates/**/*.json'],
66a7748d
JB
70 to: ['./assets/station-templates']
71 }
72 ]
73 })
74 ]
75 })
76 console.timeEnd('Build time')
77})()