Prepare the code for ESM support
[e-mobility-charging-stations-simulator.git] / rollup.config.mjs
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/ui/httpd/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 'express',
27 'fs',
28 '@mikro-orm/core',
29 '@mikro-orm/reflection',
30 'mnemonist/lru-map-with-delete',
31 'moment',
32 'mongodb',
33 'path',
34 'perf_hooks',
35 'poolifier',
36 'proper-lockfile',
37 'reflect-metadata',
38 'tar',
39 'url',
40 'uuid',
41 'ws',
42 'winston-daily-rotate-file',
43 'winston/lib/winston/transports/index.js',
44 'winston',
45 'worker_threads',
46 ],
47 plugins: [
48 json(),
49 ts({
50 tsconfig: 'tsconfig.json',
51 browserslist: false,
52 }),
53 isDevelopmentBuild && istanbul(),
54 del({
55 targets: ['dist/*', '!dist/assets', 'dist/assets/*.json', 'dist/assets/station-templates'],
56 }),
57 copy({
58 targets: [{ src: 'src/assets', dest: 'dist/' }],
59 }),
60 isDevelopmentBuild && analyze(),
61 ],
62 };