| 1 | /* eslint-disable n/no-unpublished-import */ |
| 2 | import { cpus } from 'node:os'; |
| 3 | |
| 4 | import json from '@rollup/plugin-json'; |
| 5 | import terser from '@rollup/plugin-terser'; |
| 6 | import typescript from '@rollup/plugin-typescript'; |
| 7 | import { copy } from '@web/rollup-plugin-copy'; |
| 8 | import analyze from 'rollup-plugin-analyzer'; |
| 9 | import del from 'rollup-plugin-delete'; |
| 10 | |
| 11 | const isDevelopmentBuild = process.env.BUILD === 'development'; |
| 12 | const isAnalyzeBuild = process.env.ANALYZE; |
| 13 | |
| 14 | export default { |
| 15 | input: ['src/start.ts', 'src/charging-station/ChargingStationWorker.ts'], |
| 16 | strictDeprecations: true, |
| 17 | output: [ |
| 18 | { |
| 19 | dir: 'dist', |
| 20 | format: 'esm', |
| 21 | sourcemap: !!isDevelopmentBuild, |
| 22 | plugins: [terser({ maxWorkers: cpus().length / 2 })], |
| 23 | }, |
| 24 | ], |
| 25 | external: [ |
| 26 | '@mikro-orm/core', |
| 27 | '@mikro-orm/reflection', |
| 28 | 'ajv', |
| 29 | 'ajv-formats', |
| 30 | 'basic-ftp', |
| 31 | 'chalk', |
| 32 | 'http-status-codes', |
| 33 | 'just-clone', |
| 34 | 'just-merge', |
| 35 | 'mnemonist/lru-map-with-delete.js', |
| 36 | 'mnemonist/queue.js', |
| 37 | 'moment', |
| 38 | 'mongodb', |
| 39 | 'node:async_hooks', |
| 40 | 'node:crypto', |
| 41 | 'node:events', |
| 42 | 'node:fs', |
| 43 | 'node:http', |
| 44 | 'node:path', |
| 45 | 'node:perf_hooks', |
| 46 | 'node:stream', |
| 47 | 'node:url', |
| 48 | 'node:util', |
| 49 | 'node:worker_threads', |
| 50 | 'poolifier', |
| 51 | 'tar', |
| 52 | 'winston', |
| 53 | 'winston-daily-rotate-file', |
| 54 | 'winston/lib/winston/transports/index.js', |
| 55 | 'ws', |
| 56 | ], |
| 57 | plugins: [ |
| 58 | json(), |
| 59 | typescript({ |
| 60 | tsconfig: 'tsconfig.json', |
| 61 | compilerOptions: { |
| 62 | sourceMap: !!isDevelopmentBuild, |
| 63 | }, |
| 64 | }), |
| 65 | del({ |
| 66 | targets: [ |
| 67 | 'dist/*', |
| 68 | '!dist/assets', |
| 69 | 'dist/assets/*.json', |
| 70 | 'dist/assets/json-schemas', |
| 71 | 'dist/assets/station-templates', |
| 72 | 'dist/assets/ui-protocol', |
| 73 | ], |
| 74 | }), |
| 75 | copy({ |
| 76 | rootDir: 'src', |
| 77 | patterns: 'assets/**/*.json', |
| 78 | exclude: [ |
| 79 | 'assets/config-template.json', |
| 80 | 'assets/*config[-_.]*.json', |
| 81 | 'assets/idtags-template.json', |
| 82 | 'assets/authorization-tags-template.json', |
| 83 | 'assets/ui-protocol/**/*', |
| 84 | ], |
| 85 | }), |
| 86 | isAnalyzeBuild && analyze(), |
| 87 | ], |
| 88 | }; |