Improve charging profiles handling debug logs
[e-mobility-charging-stations-simulator.git] / rollup.config.mjs
1 import json from '@rollup/plugin-json';
2 import analyze from 'rollup-plugin-analyzer';
3 import copy from 'rollup-plugin-copy';
4 import del from 'rollup-plugin-delete';
5 import { terser } from 'rollup-plugin-terser';
6 import ts from 'rollup-plugin-ts';
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: 'es',
16 exports: 'auto',
17 sourcemap: true,
18 preserveModules: true,
19 preserveModulesRoot: 'src',
20 entryFileNames: '[name].mjs',
21 ...(!isDevelopmentBuild && { plugins: [terser({ numWorkers: 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({ numWorkers: 2 })] }),
32 },
33 ],
34 external: [
35 '@mikro-orm/core',
36 '@mikro-orm/reflection',
37 'ajv',
38 'ajv-formats',
39 'async_hooks',
40 'basic-ftp',
41 'chalk',
42 'crypto',
43 'fs',
44 'http',
45 'http-status-codes',
46 'just-clone',
47 'just-merge',
48 'mnemonist/lru-map-with-delete',
49 'moment',
50 'mongodb',
51 'path',
52 'perf_hooks',
53 'poolifier',
54 'proper-lockfile',
55 'tar',
56 'url',
57 'winston',
58 'winston-daily-rotate-file',
59 'winston/lib/winston/transports',
60 'worker_threads',
61 'ws',
62 ],
63 plugins: [
64 json(),
65 ts({
66 tsconfig: 'tsconfig.json',
67 browserslist: false,
68 }),
69 del({
70 targets: [
71 'dist/*',
72 '!dist/assets',
73 'dist/assets/*.json',
74 'dist/assets/station-templates',
75 'dist/assets/json-schemas',
76 ],
77 }),
78 copy({
79 targets: [{ src: 'src/assets', dest: 'dist/' }],
80 }),
81 isDevelopmentBuild && analyze(),
82 ],
83 };