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