| 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 | entryNames: '[name]', |
| 21 | outdir: './dist', |
| 22 | banner: { |
| 23 | js: "import { createRequire } from 'module';const require = createRequire(import.meta.url);", |
| 24 | }, |
| 25 | plugins: [ |
| 26 | clean({ |
| 27 | patterns: [ |
| 28 | './dist/*', |
| 29 | '!./dist/assets', |
| 30 | './dist/assets/*.json', |
| 31 | './dist/assets/json-schemas', |
| 32 | './dist/assets/station-templates', |
| 33 | './dist/assets/ui-protocol', |
| 34 | ], |
| 35 | }), |
| 36 | copy({ |
| 37 | assets: [ |
| 38 | { |
| 39 | from: ['./src/assets/config.json'], |
| 40 | to: ['./assets'], |
| 41 | }, |
| 42 | { |
| 43 | from: ['./src/assets/idtags!(-template)*.json'], |
| 44 | to: ['./assets'], |
| 45 | }, |
| 46 | { |
| 47 | from: ['./src/assets/json-schemas/**/*.json'], |
| 48 | to: ['./assets/json-schemas'], |
| 49 | }, |
| 50 | { |
| 51 | from: ['./src/assets/station-templates/**/*.json'], |
| 52 | to: ['./assets/station-templates'], |
| 53 | }, |
| 54 | ], |
| 55 | }), |
| 56 | ], |
| 57 | }); |
| 58 | })(); |