build(simulator): don't preserve modules
[e-mobility-charging-stations-simulator.git] / rollup.config.mjs
CommitLineData
653b69b4 1/* eslint-disable n/no-unpublished-import */
f412fe24 2import json from '@rollup/plugin-json';
8b6da988
JB
3import terser from '@rollup/plugin-terser';
4import typescript from '@rollup/plugin-typescript';
cb1948a3 5import analyze from 'rollup-plugin-analyzer';
c4a19794 6import copy from 'rollup-plugin-copy';
44b07a21 7import del from 'rollup-plugin-delete';
44b07a21 8
1d064457 9const isDevelopmentBuild = process.env.BUILD === 'development';
51022aa0 10const isAnalyzeBuild = process.env.ANALYZE;
1d064457 11
44b07a21 12export default {
5a010bf0 13 input: ['src/start.ts', 'src/charging-station/ChargingStationWorker.ts'],
b768993d 14 strictDeprecations: true,
44a95b7f
JB
15 output: [
16 {
17 dir: 'dist',
2896e06d 18 format: 'esm',
44a95b7f 19 exports: 'auto',
51022aa0 20 ...(isDevelopmentBuild && { sourcemap: true }),
8b6da988 21 ...(!isDevelopmentBuild && { plugins: [terser({ maxWorkers: 2 })] }),
44a95b7f 22 },
44a95b7f 23 ],
e7aeea18 24 external: [
e3018bc4
JB
25 '@mikro-orm/core',
26 '@mikro-orm/reflection',
27 'ajv',
e3018bc4 28 'ajv-formats',
e7aeea18
JB
29 'basic-ftp',
30 'chalk',
852a4c5f 31 'http-status-codes',
088ee3c1
JB
32 'just-clone',
33 'just-merge',
b768993d 34 'mnemonist/lru-map-with-delete.js',
0bb3ee61 35 'moment',
e7aeea18 36 'mongodb',
01f4001e 37 'node:async_hooks',
0c7370da 38 'node:crypto',
130783a7 39 'node:fs',
01f4001e 40 'node:http',
130783a7 41 'node:path',
01f4001e 42 'node:perf_hooks',
8a168938 43 'node:stream',
130783a7 44 'node:url',
0c7370da 45 'node:util',
01f4001e 46 'node:worker_threads',
e7aeea18 47 'poolifier',
e7aeea18 48 'tar',
e3018bc4 49 'winston',
e7aeea18 50 'winston-daily-rotate-file',
b768993d 51 'winston/lib/winston/transports/index.js',
e3018bc4 52 'ws',
e7aeea18 53 ],
44b07a21 54 plugins: [
84e52c2c 55 json(),
8b6da988 56 typescript({
0f454015 57 tsconfig: 'tsconfig.json',
44b07a21
JB
58 }),
59 del({
045639f5
JB
60 targets: [
61 'dist/*',
62 '!dist/assets',
63 'dist/assets/*.json',
045639f5 64 'dist/assets/json-schemas',
0c995ea6
JB
65 'dist/assets/station-templates',
66 'dist/assets/ui-protocol',
045639f5 67 ],
c4a19794
JB
68 }),
69 copy({
e7aeea18 70 targets: [{ src: 'src/assets', dest: 'dist/' }],
cb1948a3 71 }),
51022aa0 72 isAnalyzeBuild && analyze(),
e7aeea18 73 ],
44b07a21 74};