X-Git-Url: https://git.piment-noir.org/?a=blobdiff_plain;f=rollup.config.mjs;h=40f1d6794c150c409643c4874914fab5a0e0815c;hb=09928f74f76348923afd66df7e72933f30ab9534;hp=2c8d35564c05b9925bfaf91e3c39f4aa582abc7d;hpb=8334d3299f3c0c62a4a819b4b696281f547d3b1c;p=e-mobility-charging-stations-simulator.git diff --git a/rollup.config.mjs b/rollup.config.mjs index 2c8d3556..40f1d679 100644 --- a/rollup.config.mjs +++ b/rollup.config.mjs @@ -1,10 +1,12 @@ /* eslint-disable n/no-unpublished-import */ import * as os from 'node:os'; +import { env } from 'node:process'; import json from '@rollup/plugin-json'; import terser from '@rollup/plugin-terser'; import typescript from '@rollup/plugin-typescript'; import { copy } from '@web/rollup-plugin-copy'; +import { defineConfig } from 'rollup'; import analyze from 'rollup-plugin-analyzer'; import del from 'rollup-plugin-delete'; @@ -14,24 +16,24 @@ const availableParallelism = () => { try { availableParallelism = os.availableParallelism(); } catch { - const numberOfCpus = os.cpus(); - if (Array.isArray(numberOfCpus) && numberOfCpus.length > 0) { - availableParallelism = numberOfCpus.length; + const cpus = os.cpus(); + if (Array.isArray(cpus) && cpus.length > 0) { + availableParallelism = cpus.length; } } return availableParallelism; }; -const isDevelopmentBuild = process.env.BUILD === 'development'; -const isAnalyzeBuild = process.env.ANALYZE; +const isDevelopmentBuild = env.BUILD === 'development'; +const isAnalyzeBuild = env.ANALYZE; const sourceMap = !!isDevelopmentBuild; -export default { - input: ['src/start.ts', 'src/charging-station/ChargingStationWorker.ts'], +export default defineConfig({ + input: ['./src/start.ts', './src/charging-station/ChargingStationWorker.ts'], strictDeprecations: true, output: [ { - dir: 'dist', + dir: './dist', format: 'esm', sourcemap: sourceMap, plugins: [terser({ maxWorkers: Math.floor(availableParallelism() / 2) })], @@ -59,6 +61,7 @@ export default { 'node:http2', 'node:path', 'node:perf_hooks', + 'node:process', 'node:stream', 'node:url', 'node:util', @@ -73,23 +76,23 @@ export default { plugins: [ json(), typescript({ - tsconfig: 'tsconfig.json', + tsconfig: './tsconfig.json', compilerOptions: { sourceMap, }, }), del({ targets: [ - 'dist/*', - '!dist/assets', - 'dist/assets/*.json', - 'dist/assets/json-schemas', - 'dist/assets/station-templates', - 'dist/assets/ui-protocol', + './dist/*', + '!./dist/assets', + './dist/assets/*.json', + './dist/assets/json-schemas', + './dist/assets/station-templates', + './dist/assets/ui-protocol', ], }), copy({ - rootDir: 'src', + rootDir: './src', patterns: 'assets/**/*.json', exclude: [ 'assets/config-template.json', @@ -101,4 +104,4 @@ export default { }), isAnalyzeBuild && analyze(), ], -}; +});