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