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