General guidance documentation (#233)
[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'
f4162974 7const isAnalyze = process.env.ANALYZE
660940b0
JB
8
9export default {
10 input: 'src/index.ts',
f4162974
JB
11 output: {
12 ...(isDevelopmentBuild ? { dir: 'lib' } : { file: 'lib/index.js' }),
13 format: 'cjs',
14 sourcemap: !!isDevelopmentBuild,
15 ...(isDevelopmentBuild && { preserveModules: true }),
16 ...(isDevelopmentBuild && { preserveModulesRoot: 'src' }),
17 ...(!isDevelopmentBuild && { plugins: [terser({ numWorkers: 2 })] })
18 },
660940b0
JB
19 external: ['async_hooks', 'cluster', 'events', 'worker_threads'],
20 plugins: [
7977150f 21 typescript({
660940b0
JB
22 tsconfig: isDevelopmentBuild
23 ? 'tsconfig.development.json'
24 : 'tsconfig.json'
25 }),
26 del({
f4162974 27 targets: ['lib/*']
f45e4999 28 }),
f4162974 29 isAnalyze && analyze()
660940b0
JB
30 ]
31}