X-Git-Url: https://git.piment-noir.org/?a=blobdiff_plain;ds=sidebyside;f=rollup.config.mjs;h=1034ffc812825d1adcc7005ac13ce24f48b8f02d;hb=bf10ea967a8f5d2cfc119d0fca405b6224b83b28;hp=a0128a547b2bcb4cbf8999e37157aefaf885da00;hpb=b768993dd4636df8276b0ea47158dd9bdc9a997b;p=e-mobility-charging-stations-simulator.git diff --git a/rollup.config.mjs b/rollup.config.mjs index a0128a54..1034ffc8 100644 --- a/rollup.config.mjs +++ b/rollup.config.mjs @@ -1,11 +1,15 @@ +/* eslint-disable n/no-unpublished-import */ +import { cpus } from 'node:os'; + 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 analyze from 'rollup-plugin-analyzer'; -import copy from 'rollup-plugin-copy'; import del from 'rollup-plugin-delete'; const isDevelopmentBuild = process.env.BUILD === 'development'; +const isAnalyzeBuild = process.env.ANALYZE; export default { input: ['src/start.ts', 'src/charging-station/ChargingStationWorker.ts'], @@ -14,22 +18,8 @@ export default { { dir: 'dist', format: 'esm', - exports: 'auto', - sourcemap: true, - preserveModules: true, - preserveModulesRoot: 'src', - entryFileNames: '[name].mjs', - ...(!isDevelopmentBuild && { plugins: [terser({ maxWorkers: 2 })] }), - }, - { - dir: 'dist', - format: 'cjs', - exports: 'auto', - sourcemap: true, - preserveModules: true, - preserveModulesRoot: 'src', - entryFileNames: '[name].cjs', - ...(!isDevelopmentBuild && { plugins: [terser({ maxWorkers: 2 })] }), + sourcemap: !!isDevelopmentBuild, + plugins: [terser({ maxWorkers: cpus().length / 2 })], }, ], external: [ @@ -43,10 +33,12 @@ export default { 'just-clone', 'just-merge', 'mnemonist/lru-map-with-delete.js', + 'mnemonist/queue.js', 'moment', 'mongodb', 'node:async_hooks', 'node:crypto', + 'node:events', 'node:fs', 'node:http', 'node:path', @@ -56,7 +48,6 @@ export default { 'node:util', 'node:worker_threads', 'poolifier', - 'proper-lockfile', 'tar', 'winston', 'winston-daily-rotate-file', @@ -67,19 +58,31 @@ export default { json(), typescript({ tsconfig: 'tsconfig.json', + compilerOptions: { + sourceMap: !!isDevelopmentBuild, + }, }), del({ targets: [ 'dist/*', '!dist/assets', 'dist/assets/*.json', - 'dist/assets/station-templates', 'dist/assets/json-schemas', + 'dist/assets/station-templates', + 'dist/assets/ui-protocol', ], }), copy({ - targets: [{ src: 'src/assets', dest: 'dist/' }], + rootDir: 'src', + patterns: 'assets/**/*.json', + exclude: [ + 'assets/config-template.json', + 'assets/*config[-_.]*.json', + 'assets/idtags-template.json', + 'assets/authorization-tags-template.json', + 'assets/ui-protocol/**/*', + ], }), - isDevelopmentBuild && analyze(), + isAnalyzeBuild && analyze(), ], };