build(deps-dev): bump vite from 5.2.7 to 5.2.8
[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
f36c2478
JB
9const isDevelopmentBuild = env.BUILD === 'development'
10const sourcemap = !!isDevelopmentBuild
11console.info(chalk.green(`Building in ${isDevelopmentBuild ? 'development' : 'production'} mode`))
12console.time('Build time')
13await 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',
24dc52e9 25 'date-fns/*',
f36c2478 26 'http-status-codes',
f36c2478 27 'logform',
e80de0da 28 'mnemonist',
f36c2478
JB
29 'mongodb',
30 'node:*',
31 'poolifier',
b4c82e73 32 'rambda',
f36c2478
JB
33 'tar',
34 'winston',
35 'winston/*',
36 'winston-daily-rotate-file',
37 'ws'
38 ],
c4d48eae 39 treeShaking: true,
f36c2478
JB
40 minify: true,
41 sourcemap,
42 entryNames: '[name]',
43 outdir: './dist',
44 plugins: [
45 clean({
46 patterns: [
47 './dist/*',
48 '!./dist/assets',
49 './dist/assets/*.json',
50 './dist/assets/json-schemas',
51 './dist/assets/station-templates',
830edb98
JB
52 './dist/assets/ui-protocol',
53 './dist/assets/configs-docker'
f36c2478
JB
54 ]
55 }),
56 copy({
57 assets: [
58 {
59 from: ['./src/assets/config.json'],
60 to: ['./assets']
61 },
62 {
63 from: ['./src/assets/idtags!(-template)*.json'],
64 to: ['./assets']
65 },
66 {
67 from: ['./src/assets/json-schemas/**/*.json'],
68 to: ['./assets/json-schemas']
69 },
70 {
71 from: ['./src/assets/station-templates/**/*.json'],
72 to: ['./assets/station-templates']
830edb98
JB
73 },
74 {
75 from: ['./src/assets/configs-docker/*.json'],
76 to: ['./assets/configs-docker']
f36c2478
JB
77 }
78 ]
79 })
80 ]
81})
82console.timeEnd('Build time')