Commit | Line | Data |
---|---|---|
44ebef4c JB |
1 | /* eslint-disable n/no-unpublished-import */ |
2 | import { env } from 'node:process'; | |
3 | ||
78202698 | 4 | import chalk from 'chalk'; |
44ebef4c JB |
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 | ||
78202698 | 12 | console.info(chalk.green(`Building in ${isDevelopmentBuild ? 'development' : 'production'} mode`)); |
44ebef4c | 13 | (async () => { |
ce1b06a7 | 14 | console.time('Build time'); |
44ebef4c JB |
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 | }); | |
ce1b06a7 | 77 | console.timeEnd('Build time'); |
44ebef4c | 78 | })(); |