build(simulator): always minify bundle
[e-mobility-charging-stations-simulator.git] / rollup.config.mjs
1 /* eslint-disable n/no-unpublished-import */
2 import os from '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: os.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 }),
61 del({
62 targets: [
63 'dist/*',
64 '!dist/assets',
65 'dist/assets/*.json',
66 'dist/assets/json-schemas',
67 'dist/assets/station-templates',
68 'dist/assets/ui-protocol',
69 ],
70 }),
71 copy({
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 ],
80 }),
81 isAnalyzeBuild && analyze(),
82 ],
83 };