Add error handling to JSON schemas file reading
[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 'http',
43 'http-status-codes',
44 'just-clone',
45 'just-merge',
46 'mnemonist/lru-map-with-delete',
47 'moment',
48 'mongodb',
49 'node:crypto',
50 'node:fs',
51 'node:path',
52 'node:url',
53 'node:util',
54 'perf_hooks',
55 'poolifier',
56 'proper-lockfile',
57 'tar',
58 'winston',
59 'winston-daily-rotate-file',
60 'winston/lib/winston/transports',
61 'worker_threads',
62 'ws',
63 ],
64 plugins: [
65 json(),
66 ts({
67 tsconfig: 'tsconfig.json',
68 browserslist: false,
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 };