| 1 | /* eslint-disable n/no-unpublished-import */ |
| 2 | import json from '@rollup/plugin-json'; |
| 3 | import terser from '@rollup/plugin-terser'; |
| 4 | import typescript from '@rollup/plugin-typescript'; |
| 5 | import analyze from 'rollup-plugin-analyzer'; |
| 6 | import copy from 'rollup-plugin-copy'; |
| 7 | import del from 'rollup-plugin-delete'; |
| 8 | |
| 9 | const isDevelopmentBuild = process.env.BUILD === 'development'; |
| 10 | |
| 11 | export default { |
| 12 | input: ['src/start.ts', 'src/charging-station/ChargingStationWorker.ts'], |
| 13 | strictDeprecations: true, |
| 14 | output: [ |
| 15 | { |
| 16 | dir: 'dist', |
| 17 | format: 'esm', |
| 18 | exports: 'auto', |
| 19 | sourcemap: true, |
| 20 | preserveModules: true, |
| 21 | preserveModulesRoot: 'src', |
| 22 | entryFileNames: '[name].mjs', |
| 23 | ...(!isDevelopmentBuild && { plugins: [terser({ maxWorkers: 2 })] }), |
| 24 | }, |
| 25 | ], |
| 26 | external: [ |
| 27 | '@mikro-orm/core', |
| 28 | '@mikro-orm/reflection', |
| 29 | 'ajv', |
| 30 | 'ajv-formats', |
| 31 | 'basic-ftp', |
| 32 | 'chalk', |
| 33 | 'http-status-codes', |
| 34 | 'just-clone', |
| 35 | 'just-merge', |
| 36 | 'mnemonist/lru-map-with-delete.js', |
| 37 | 'moment', |
| 38 | 'mongodb', |
| 39 | 'node:async_hooks', |
| 40 | 'node:crypto', |
| 41 | 'node:fs', |
| 42 | 'node:http', |
| 43 | 'node:path', |
| 44 | 'node:perf_hooks', |
| 45 | 'node:stream', |
| 46 | 'node:url', |
| 47 | 'node:util', |
| 48 | 'node:worker_threads', |
| 49 | 'poolifier', |
| 50 | 'proper-lockfile', |
| 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 | }), |
| 62 | del({ |
| 63 | targets: [ |
| 64 | 'dist/*', |
| 65 | '!dist/assets', |
| 66 | 'dist/assets/*.json', |
| 67 | 'dist/assets/json-schemas', |
| 68 | 'dist/assets/station-templates', |
| 69 | 'dist/assets/ui-protocol', |
| 70 | ], |
| 71 | }), |
| 72 | copy({ |
| 73 | targets: [{ src: 'src/assets', dest: 'dist/' }], |
| 74 | }), |
| 75 | isDevelopmentBuild && analyze(), |
| 76 | ], |
| 77 | }; |