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