1 /* eslint-disable n/no-unpublished-import */
2 import * as os from 'node:os';
3 import { env } from 'node:process';
5 import json from '@rollup/plugin-json';
6 import terser from '@rollup/plugin-terser';
7 import typescript from '@rollup/plugin-typescript';
8 import { copy } from '@web/rollup-plugin-copy';
9 import { defineConfig } from 'rollup';
10 import analyze from 'rollup-plugin-analyzer';
11 import del from 'rollup-plugin-delete';
13 const availableParallelism = () => {
14 // eslint-disable-next-line no-shadow
15 let availableParallelism = 1;
17 availableParallelism = os.availableParallelism();
19 const cpus = os.cpus();
20 if (Array.isArray(cpus) && cpus.length > 0) {
21 availableParallelism = cpus.length;
24 return availableParallelism;
27 const isDevelopmentBuild = env.BUILD === 'development';
28 const isAnalyzeBuild = env.ANALYZE;
29 const sourceMap = !!isDevelopmentBuild;
31 export default defineConfig({
32 input: ['./src/start.ts', './src/charging-station/ChargingStationWorker.ts'],
33 strictDeprecations: true,
39 plugins: [terser({ maxWorkers: Math.floor(availableParallelism() / 2) })],
44 '@mikro-orm/reflection',
53 'mnemonist/lru-map-with-delete.js',
68 'node:worker_threads',
72 'winston-daily-rotate-file',
73 'winston/lib/winston/transports/index.js',
79 tsconfig: './tsconfig.json',
88 './dist/assets/*.json',
89 './dist/assets/json-schemas',
90 './dist/assets/station-templates',
91 './dist/assets/ui-protocol',
96 patterns: 'assets/**/*.json',
98 'assets/config-template.json',
99 'assets/*config[-_.]*.json',
100 'assets/idtags-template.json',
101 'assets/authorization-tags-template.json',
102 'assets/ui-protocol/**/*',
105 isAnalyzeBuild && analyze(),