Commit | Line | Data |
---|---|---|
44ebef4c | 1 | /* eslint-disable n/no-unpublished-import */ |
66a7748d | 2 | import { env } from 'node:process' |
44ebef4c | 3 | |
66a7748d JB |
4 | import chalk from 'chalk' |
5 | import { build } from 'esbuild' | |
6 | import { clean } from 'esbuild-plugin-clean' | |
7 | import { copy } from 'esbuild-plugin-copy' | |
3dfc5d50 | 8 | |
f36c2478 JB |
9 | const isDevelopmentBuild = env.BUILD === 'development' |
10 | const sourcemap = !!isDevelopmentBuild | |
11 | console.info(chalk.green(`Building in ${isDevelopmentBuild ? 'development' : 'production'} mode`)) | |
12 | console.time('Build time') | |
13 | await 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', | |
25 | 'http-status-codes', | |
26 | 'just-merge', | |
27 | 'logform', | |
e80de0da | 28 | 'mnemonist', |
f36c2478 JB |
29 | 'mongodb', |
30 | 'node:*', | |
31 | 'poolifier', | |
32 | 'tar', | |
33 | 'winston', | |
34 | 'winston/*', | |
35 | 'winston-daily-rotate-file', | |
36 | 'ws' | |
37 | ], | |
38 | minify: true, | |
39 | sourcemap, | |
40 | entryNames: '[name]', | |
41 | outdir: './dist', | |
42 | plugins: [ | |
43 | clean({ | |
44 | patterns: [ | |
45 | './dist/*', | |
46 | '!./dist/assets', | |
47 | './dist/assets/*.json', | |
48 | './dist/assets/json-schemas', | |
49 | './dist/assets/station-templates', | |
50 | './dist/assets/ui-protocol' | |
51 | ] | |
52 | }), | |
53 | copy({ | |
54 | assets: [ | |
55 | { | |
56 | from: ['./src/assets/config.json'], | |
57 | to: ['./assets'] | |
58 | }, | |
59 | { | |
60 | from: ['./src/assets/idtags!(-template)*.json'], | |
61 | to: ['./assets'] | |
62 | }, | |
63 | { | |
64 | from: ['./src/assets/json-schemas/**/*.json'], | |
65 | to: ['./assets/json-schemas'] | |
66 | }, | |
67 | { | |
68 | from: ['./src/assets/station-templates/**/*.json'], | |
69 | to: ['./assets/station-templates'] | |
70 | } | |
71 | ] | |
72 | }) | |
73 | ] | |
74 | }) | |
75 | console.timeEnd('Build time') |