Commit | Line | Data |
---|---|---|
653b69b4 | 1 | /* eslint-disable n/no-unpublished-import */ |
eadc058c | 2 | import * as os from 'node:os'; |
31b5738e | 3 | |
f412fe24 | 4 | import json from '@rollup/plugin-json'; |
8b6da988 JB |
5 | import terser from '@rollup/plugin-terser'; |
6 | import typescript from '@rollup/plugin-typescript'; | |
672551ed | 7 | import { copy } from '@web/rollup-plugin-copy'; |
cb1948a3 | 8 | import analyze from 'rollup-plugin-analyzer'; |
44b07a21 | 9 | import del from 'rollup-plugin-delete'; |
44b07a21 | 10 | |
eadc058c JB |
11 | const availableParallelism = () => { |
12 | // eslint-disable-next-line no-shadow | |
13 | let availableParallelism = 1; | |
14 | try { | |
15 | availableParallelism = os.availableParallelism(); | |
16 | } catch { | |
17 | const numberOfCpus = os.cpus(); | |
18 | if (Array.isArray(numberOfCpus) && numberOfCpus.length > 0) { | |
19 | availableParallelism = numberOfCpus.length; | |
20 | } | |
21 | } | |
22 | return availableParallelism; | |
23 | }; | |
24 | ||
1d064457 | 25 | const isDevelopmentBuild = process.env.BUILD === 'development'; |
51022aa0 | 26 | const isAnalyzeBuild = process.env.ANALYZE; |
92bee070 | 27 | const sourceMap = !!isDevelopmentBuild; |
1d064457 | 28 | |
44b07a21 | 29 | export default { |
5a010bf0 | 30 | input: ['src/start.ts', 'src/charging-station/ChargingStationWorker.ts'], |
b768993d | 31 | strictDeprecations: true, |
44a95b7f JB |
32 | output: [ |
33 | { | |
34 | dir: 'dist', | |
2896e06d | 35 | format: 'esm', |
92bee070 | 36 | sourcemap: sourceMap, |
eadc058c | 37 | plugins: [terser({ maxWorkers: Math.floor(availableParallelism() / 2) })], |
44a95b7f | 38 | }, |
44a95b7f | 39 | ], |
e7aeea18 | 40 | external: [ |
e3018bc4 JB |
41 | '@mikro-orm/core', |
42 | '@mikro-orm/reflection', | |
43 | 'ajv', | |
e3018bc4 | 44 | 'ajv-formats', |
e7aeea18 JB |
45 | 'basic-ftp', |
46 | 'chalk', | |
a675e34b | 47 | 'date-fns', |
32f5e42d | 48 | 'deep-clone', |
852a4c5f | 49 | 'http-status-codes', |
088ee3c1 | 50 | 'just-merge', |
f31d1d0c JB |
51 | 'mnemonist/lru-map-with-delete.js', |
52 | 'mnemonist/queue.js', | |
e7aeea18 | 53 | 'mongodb', |
01f4001e | 54 | 'node:async_hooks', |
0c7370da | 55 | 'node:crypto', |
942f9727 | 56 | 'node:events', |
130783a7 | 57 | 'node:fs', |
01f4001e | 58 | 'node:http', |
130783a7 | 59 | 'node:path', |
01f4001e | 60 | 'node:perf_hooks', |
8a168938 | 61 | 'node:stream', |
130783a7 | 62 | 'node:url', |
0c7370da | 63 | 'node:util', |
01f4001e | 64 | 'node:worker_threads', |
e7aeea18 | 65 | 'poolifier', |
e7aeea18 | 66 | 'tar', |
e3018bc4 | 67 | 'winston', |
e7aeea18 | 68 | 'winston-daily-rotate-file', |
b768993d | 69 | 'winston/lib/winston/transports/index.js', |
e3018bc4 | 70 | 'ws', |
e7aeea18 | 71 | ], |
44b07a21 | 72 | plugins: [ |
84e52c2c | 73 | json(), |
8b6da988 | 74 | typescript({ |
0f454015 | 75 | tsconfig: 'tsconfig.json', |
c98873ea | 76 | compilerOptions: { |
92bee070 | 77 | sourceMap, |
c98873ea | 78 | }, |
44b07a21 JB |
79 | }), |
80 | del({ | |
045639f5 JB |
81 | targets: [ |
82 | 'dist/*', | |
83 | '!dist/assets', | |
84 | 'dist/assets/*.json', | |
045639f5 | 85 | 'dist/assets/json-schemas', |
0c995ea6 JB |
86 | 'dist/assets/station-templates', |
87 | 'dist/assets/ui-protocol', | |
045639f5 | 88 | ], |
c4a19794 JB |
89 | }), |
90 | copy({ | |
672551ed JB |
91 | rootDir: 'src', |
92 | patterns: 'assets/**/*.json', | |
93 | exclude: [ | |
94 | 'assets/config-template.json', | |
70b77dcd | 95 | 'assets/*config[-_.]*.json', |
672551ed | 96 | 'assets/idtags-template.json', |
5d1a7b7d | 97 | 'assets/authorization-tags-template.json', |
672551ed JB |
98 | 'assets/ui-protocol/**/*', |
99 | ], | |
cb1948a3 | 100 | }), |
51022aa0 | 101 | isAnalyzeBuild && analyze(), |
e7aeea18 | 102 | ], |
44b07a21 | 103 | }; |