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