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