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