e660242612b1a9892dd84a0daa390819f3356dda
[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 { copy } from '@web/rollup-plugin-copy';
6 import analyze from 'rollup-plugin-analyzer';
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:events',
40 'node:fs',
41 'node:http',
42 'node:path',
43 'node:perf_hooks',
44 'node:stream',
45 'node:url',
46 'node:util',
47 'node:worker_threads',
48 'poolifier',
49 'tar',
50 'winston',
51 'winston-daily-rotate-file',
52 'winston/lib/winston/transports/index.js',
53 'ws',
54 ],
55 plugins: [
56 json(),
57 typescript({
58 tsconfig: 'tsconfig.json',
59 }),
60 del({
61 targets: [
62 'dist/*',
63 '!dist/assets',
64 'dist/assets/*.json',
65 'dist/assets/json-schemas',
66 'dist/assets/station-templates',
67 'dist/assets/ui-protocol',
68 ],
69 }),
70 copy({
71 rootDir: 'src',
72 patterns: 'assets/**/*.json',
73 exclude: [
74 'assets/config-template.json',
75 'assets/*config[-_]*.json',
76 'assets/idtags-template.json',
77 'assets/ui-protocol/**/*',
78 ],
79 }),
80 isAnalyzeBuild && analyze(),
81 ],
82 };