Build system: add bundling analysis to dev build (#150)
[poolifier.git] / rollup.config.mjs
CommitLineData
7977150f 1import typescript from 'rollup-plugin-typescript2'
f45e4999
JB
2import analyze from 'rollup-plugin-analyzer'
3import { terser } from 'rollup-plugin-terser'
660940b0 4import del from 'rollup-plugin-delete'
660940b0
JB
5
6const isDevelopmentBuild = process.env.BUILD === 'development'
7
8export default {
9 input: 'src/index.ts',
f45e4999
JB
10 output: [
11 {
12 dir: 'lib',
13 format: 'cjs',
14 sourcemap: !!isDevelopmentBuild,
15 preserveModules: true,
16 preserveModulesRoot: 'src'
17 },
18 isDevelopmentBuild && {
19 file: 'lib.min/index.js',
20 format: 'cjs',
21 sourcemap: !!isDevelopmentBuild,
22 plugins: [terser({ numWorkers: 2 })]
23 }
24 ],
660940b0
JB
25 external: ['async_hooks', 'cluster', 'events', 'worker_threads'],
26 plugins: [
7977150f 27 typescript({
660940b0
JB
28 tsconfig: isDevelopmentBuild
29 ? 'tsconfig.development.json'
30 : 'tsconfig.json'
31 }),
32 del({
f45e4999
JB
33 targets: ['lib/*', 'lib.min/*']
34 }),
35 isDevelopmentBuild && analyze()
660940b0
JB
36 ]
37}