80f99ca861c7c6b71933abe3b26a815d7e70daa7
[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 strictDeprecations: true,
13 output: [
14 {
15 dir: 'dist',
16 format: 'esm',
17 exports: 'auto',
18 sourcemap: true,
19 preserveModules: true,
20 preserveModulesRoot: 'src',
21 entryFileNames: '[name].mjs',
22 ...(!isDevelopmentBuild && { plugins: [terser({ maxWorkers: 2 })] }),
23 },
24 {
25 dir: 'dist',
26 format: 'cjs',
27 exports: 'auto',
28 sourcemap: true,
29 preserveModules: true,
30 preserveModulesRoot: 'src',
31 entryFileNames: '[name].cjs',
32 ...(!isDevelopmentBuild && { plugins: [terser({ maxWorkers: 2 })] }),
33 },
34 ],
35 external: [
36 '@mikro-orm/core',
37 '@mikro-orm/reflection',
38 'ajv',
39 'ajv-formats',
40 'basic-ftp',
41 'chalk',
42 'http-status-codes',
43 'just-clone',
44 'just-merge',
45 'mnemonist/lru-map-with-delete.js',
46 'moment',
47 'mongodb',
48 'node:async_hooks',
49 'node:crypto',
50 'node:fs',
51 'node:http',
52 'node:path',
53 'node:perf_hooks',
54 'node:stream',
55 'node:url',
56 'node:util',
57 'node:worker_threads',
58 'poolifier',
59 'proper-lockfile',
60 'tar',
61 'winston',
62 'winston-daily-rotate-file',
63 'winston/lib/winston/transports/index.js',
64 'ws',
65 ],
66 plugins: [
67 json(),
68 typescript({
69 tsconfig: 'tsconfig.json',
70 }),
71 del({
72 targets: [
73 'dist/*',
74 '!dist/assets',
75 'dist/assets/*.json',
76 'dist/assets/json-schemas',
77 'dist/assets/station-templates',
78 'dist/assets/ui-protocol',
79 ],
80 }),
81 copy({
82 targets: [{ src: 'src/assets', dest: 'dist/' }],
83 }),
84 isDevelopmentBuild && analyze(),
85 ],
86 };