| 1 | import analyze from 'rollup-plugin-analyzer'; |
| 2 | import copy from 'rollup-plugin-copy'; |
| 3 | import del from 'rollup-plugin-delete'; |
| 4 | import istanbul from 'rollup-plugin-istanbul'; |
| 5 | import json from '@rollup/plugin-json'; |
| 6 | import { terser } from 'rollup-plugin-terser'; |
| 7 | import ts from 'rollup-plugin-ts'; |
| 8 | |
| 9 | const isDevelopmentBuild = process.env.BUILD === 'development'; |
| 10 | |
| 11 | export default { |
| 12 | input: ['src/start.ts', 'src/charging-station/ChargingStationWorker.ts'], |
| 13 | output: { |
| 14 | dir: 'dist', |
| 15 | format: 'cjs', |
| 16 | exports: 'auto', |
| 17 | sourcemap: true, |
| 18 | preserveModules: true, |
| 19 | preserveModulesRoot: 'src', |
| 20 | ...(!isDevelopmentBuild && { plugins: [terser({ numWorkers: 2 })] }), |
| 21 | }, |
| 22 | external: [ |
| 23 | 'basic-ftp', |
| 24 | 'chalk', |
| 25 | 'crypto', |
| 26 | 'fs', |
| 27 | '@mikro-orm/core', |
| 28 | '@mikro-orm/reflection', |
| 29 | 'mongodb', |
| 30 | 'path', |
| 31 | 'perf_hooks', |
| 32 | 'poolifier', |
| 33 | 'proper-lockfile', |
| 34 | 'reflect-metadata', |
| 35 | 'tar', |
| 36 | 'url', |
| 37 | 'uuid', |
| 38 | 'ws', |
| 39 | 'winston-daily-rotate-file', |
| 40 | 'winston/lib/winston/transports', |
| 41 | 'winston', |
| 42 | 'worker_threads', |
| 43 | ], |
| 44 | plugins: [ |
| 45 | json(), |
| 46 | ts({ |
| 47 | tsconfig: 'tsconfig.json', |
| 48 | browserslist: false, |
| 49 | }), |
| 50 | isDevelopmentBuild && istanbul(), |
| 51 | del({ |
| 52 | targets: ['dist/*', '!dist/assets', 'dist/assets/*.json', 'dist/assets/station-templates'], |
| 53 | }), |
| 54 | copy({ |
| 55 | targets: [{ src: 'src/assets', dest: 'dist/' }], |
| 56 | }), |
| 57 | isDevelopmentBuild && analyze(), |
| 58 | ], |
| 59 | }; |