+import analyze from 'rollup-plugin-analyzer';
+import copy from 'rollup-plugin-copy';
import del from 'rollup-plugin-delete';
-import ts from '@wessberg/rollup-plugin-ts';
+import istanbul from 'rollup-plugin-istanbul';
+import json from '@rollup/plugin-json';
+import { terser } from 'rollup-plugin-terser';
+import ts from 'rollup-plugin-ts';
+
+const isDevelopmentBuild = process.env.BUILD === 'development';
export default {
- input: ['src/start.ts', 'src/charging-station/StationWorker.ts'],
+ input: ['src/start.ts', 'src/ui/httpd/start.ts', 'src/charging-station/ChargingStationWorker.ts'],
output: {
dir: 'dist',
format: 'cjs',
exports: 'auto',
sourcemap: true,
preserveModules: true,
- preserveModulesRoot: 'src'
+ preserveModulesRoot: 'src',
+ ...(!isDevelopmentBuild && { plugins: [terser({ numWorkers: 2 })] }),
},
- external: ['crypto', 'perf_hooks', 'fs', 'poolifier', 'uuid', 'ws', 'winston', 'winston-daily-rotate-file', 'worker_threads'],
+ external: [
+ 'basic-ftp',
+ 'chalk',
+ 'crypto',
+ 'express',
+ 'fs',
+ '@mikro-orm/core',
+ '@mikro-orm/reflection',
+ 'mongodb',
+ 'path',
+ 'perf_hooks',
+ 'poolifier',
+ 'proper-lockfile',
+ 'reflect-metadata',
+ 'tar',
+ 'url',
+ 'uuid',
+ 'ws',
+ 'winston-daily-rotate-file',
+ 'winston/lib/winston/transports',
+ 'winston',
+ 'worker_threads',
+ ],
plugins: [
+ json(),
ts({
- tsconfig: 'tsconfig.json'
+ tsconfig: 'tsconfig.json',
+ browserslist: false,
}),
+ isDevelopmentBuild && istanbul(),
del({
- targets: 'dist/*'
- })
- ]
+ targets: ['dist/*', '!dist/assets', 'dist/assets/*.json', 'dist/assets/station-templates'],
+ }),
+ copy({
+ targets: [{ src: 'src/assets', dest: 'dist/' }],
+ }),
+ isDevelopmentBuild && analyze(),
+ ],
};