Update dependencies
[e-mobility-charging-stations-simulator.git] / rollup.config.js
index 9a8b5955b315e4bcac6905f4271171ff379ebd82..0cc0ef5b1d088b7e148b7e476be77c389e7ca7a6 100644 (file)
@@ -1,23 +1,61 @@
+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',
+    'moment',
+    '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(),
+  ],
 };