build: rollup -> esbuild
[e-mobility-charging-stations-simulator.git] / bundle.js
1 /* eslint-disable n/no-unpublished-import */
2 import { env } from 'node:process';
3
4 import { build } from 'esbuild';
5 import { clean } from 'esbuild-plugin-clean';
6 import { copy } from 'esbuild-plugin-copy';
7
8 const isDevelopmentBuild = env.BUILD === 'development';
9 const sourcemap = !!isDevelopmentBuild;
10
11 (async () => {
12 await build({
13 entryPoints: ['./src/start.ts', './src/charging-station/ChargingStationWorker.ts'],
14 bundle: true,
15 platform: 'node',
16 format: 'esm',
17 external: ['@mikro-orm/*'],
18 minify: true,
19 sourcemap,
20 outdir: './dist',
21 plugins: [
22 clean({
23 patterns: [
24 './dist/*',
25 '!./dist/assets',
26 './dist/assets/*.json',
27 './dist/assets/json-schemas',
28 './dist/assets/station-templates',
29 './dist/assets/ui-protocol',
30 ],
31 }),
32 copy({
33 assets: [
34 {
35 from: ['./src/assets/config.json'],
36 to: ['./assets'],
37 },
38 {
39 from: ['./src/assets/idtags!(-template)*.json'],
40 to: ['./assets'],
41 },
42 {
43 from: ['./src/assets/json-schemas/**/*.json'],
44 to: ['./assets/json-schemas'],
45 },
46 {
47 from: ['./src/assets/station-templates/**/*.json'],
48 to: ['./assets/station-templates'],
49 },
50 ],
51 }),
52 ],
53 });
54 })();