Prepare the code for ESM support
[e-mobility-charging-stations-simulator.git] / rollup.config.mjs
CommitLineData
cb1948a3 1import analyze from 'rollup-plugin-analyzer';
c4a19794 2import copy from 'rollup-plugin-copy';
44b07a21 3import del from 'rollup-plugin-delete';
4082efc1 4import istanbul from 'rollup-plugin-istanbul';
84e52c2c 5import json from '@rollup/plugin-json';
fc201913 6import { terser } from 'rollup-plugin-terser';
ae8ee665 7import ts from 'rollup-plugin-ts';
44b07a21 8
1d064457
JB
9const isDevelopmentBuild = process.env.BUILD === 'development';
10
44b07a21 11export default {
903becc3 12 input: ['src/start.ts', 'src/ui/httpd/start.ts', 'src/charging-station/ChargingStationWorker.ts'],
e7aeea18 13 output: {
44b07a21
JB
14 dir: 'dist',
15 format: 'cjs',
16 exports: 'auto',
17 sourcemap: true,
18 preserveModules: true,
fc201913 19 preserveModulesRoot: 'src',
e7aeea18 20 ...(!isDevelopmentBuild && { plugins: [terser({ numWorkers: 2 })] }),
44b07a21 21 },
e7aeea18
JB
22 external: [
23 'basic-ftp',
24 'chalk',
25 'crypto',
175d4f46 26 'express',
e7aeea18
JB
27 'fs',
28 '@mikro-orm/core',
29 '@mikro-orm/reflection',
7c72977b 30 'mnemonist/lru-map-with-delete',
0bb3ee61 31 'moment',
e7aeea18
JB
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',
0d8140bd 43 'winston/lib/winston/transports/index.js',
e7aeea18
JB
44 'winston',
45 'worker_threads',
46 ],
44b07a21 47 plugins: [
84e52c2c 48 json(),
ae8ee665
JB
49 ts({
50 tsconfig: 'tsconfig.json',
e7aeea18 51 browserslist: false,
44b07a21 52 }),
4082efc1 53 isDevelopmentBuild && istanbul(),
44b07a21 54 del({
073bd098 55 targets: ['dist/*', '!dist/assets', 'dist/assets/*.json', 'dist/assets/station-templates'],
c4a19794
JB
56 }),
57 copy({
e7aeea18 58 targets: [{ src: 'src/assets', dest: 'dist/' }],
cb1948a3 59 }),
e7aeea18
JB
60 isDevelopmentBuild && analyze(),
61 ],
44b07a21 62};