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 | ||
12 | (async () => { | |
fc04731e JB |
13 | console.info( |
14 | chalk.green(`Building in ${isDevelopmentBuild ? 'development' : 'production'} mode`), | |
15 | ); | |
ce1b06a7 | 16 | console.time('Build time'); |
44ebef4c JB |
17 | await build({ |
18 | entryPoints: ['./src/start.ts', './src/charging-station/ChargingStationWorker.ts'], | |
19 | bundle: true, | |
20 | platform: 'node', | |
21 | format: 'esm', | |
ae2f5292 JB |
22 | external: [ |
23 | '@mikro-orm/*', | |
24 | 'ajv', | |
25 | 'ajv-formats', | |
26 | 'basic-ftp', | |
27 | 'chalk', | |
28 | 'date-fns', | |
29 | 'http-status-codes', | |
30 | 'just-merge', | |
31 | 'logform', | |
ab34592f | 32 | 'mnemonist/*', |
ae2f5292 JB |
33 | 'mongodb', |
34 | 'node:*', | |
35 | 'poolifier', | |
36 | 'tar', | |
37 | 'winston', | |
ab34592f | 38 | 'winston/*', |
ae2f5292 JB |
39 | 'winston-daily-rotate-file', |
40 | 'ws', | |
41 | ], | |
44ebef4c JB |
42 | minify: true, |
43 | sourcemap, | |
4eeee49c | 44 | entryNames: '[name]', |
44ebef4c JB |
45 | outdir: './dist', |
46 | plugins: [ | |
47 | clean({ | |
48 | patterns: [ | |
49 | './dist/*', | |
50 | '!./dist/assets', | |
51 | './dist/assets/*.json', | |
52 | './dist/assets/json-schemas', | |
53 | './dist/assets/station-templates', | |
54 | './dist/assets/ui-protocol', | |
55 | ], | |
56 | }), | |
57 | copy({ | |
58 | assets: [ | |
59 | { | |
60 | from: ['./src/assets/config.json'], | |
61 | to: ['./assets'], | |
62 | }, | |
63 | { | |
64 | from: ['./src/assets/idtags!(-template)*.json'], | |
65 | to: ['./assets'], | |
66 | }, | |
67 | { | |
68 | from: ['./src/assets/json-schemas/**/*.json'], | |
69 | to: ['./assets/json-schemas'], | |
70 | }, | |
71 | { | |
72 | from: ['./src/assets/station-templates/**/*.json'], | |
73 | to: ['./assets/station-templates'], | |
74 | }, | |
75 | ], | |
76 | }), | |
77 | ], | |
78 | }); | |
ce1b06a7 | 79 | console.timeEnd('Build time'); |
44ebef4c | 80 | })(); |