2f1c5d69f5691999189e53d8e3a9bbef39686500
[e-mobility-charging-stations-simulator.git] / rollup.config.mjs
1 import json from '@rollup/plugin-json';
2 import analyze from 'rollup-plugin-analyzer';
3 import copy from 'rollup-plugin-copy';
4 import del from 'rollup-plugin-delete';
5 import istanbul from 'rollup-plugin-istanbul';
6 import { terser } from 'rollup-plugin-terser';
7 import ts from 'rollup-plugin-ts';
8
9 const isDevelopmentBuild = process.env.BUILD === 'development';
10
11 export default {
12 input: ['src/start.ts', 'src/charging-station/ChargingStationWorker.ts'],
13 output: [
14 {
15 dir: 'dist',
16 format: 'es',
17 exports: 'auto',
18 sourcemap: true,
19 preserveModules: true,
20 preserveModulesRoot: 'src',
21 entryFileNames: '[name].mjs',
22 ...(!isDevelopmentBuild && { plugins: [terser({ numWorkers: 2 })] }),
23 },
24 {
25 dir: 'dist',
26 format: 'cjs',
27 exports: 'auto',
28 sourcemap: true,
29 preserveModules: true,
30 preserveModulesRoot: 'src',
31 entryFileNames: '[name].cjs',
32 ...(!isDevelopmentBuild && { plugins: [terser({ numWorkers: 2 })] }),
33 },
34 ],
35 external: [
36 '@mikro-orm/core',
37 '@mikro-orm/reflection',
38 'ajv',
39 'ajv-draft-04',
40 'ajv-formats',
41 'basic-ftp',
42 'chalk',
43 'crypto',
44 'fs',
45 'mnemonist/lru-map-with-delete',
46 'moment',
47 'mongodb',
48 'path',
49 'perf_hooks',
50 'poolifier',
51 'proper-lockfile',
52 'reflect-metadata',
53 'tar',
54 'url',
55 'uuid',
56 'winston',
57 'winston-daily-rotate-file',
58 'winston/lib/winston/transports/index.js',
59 'worker_threads',
60 'ws',
61 ],
62 plugins: [
63 json(),
64 ts({
65 tsconfig: 'tsconfig.json',
66 browserslist: false,
67 }),
68 isDevelopmentBuild && istanbul(),
69 del({
70 targets: [
71 'dist/*',
72 '!dist/assets',
73 'dist/assets/*.json',
74 'dist/assets/station-templates',
75 'dist/assets/json-schemas',
76 ],
77 }),
78 copy({
79 targets: [{ src: 'src/assets', dest: 'dist/' }],
80 }),
81 isDevelopmentBuild && analyze(),
82 ],
83 };