build: silence warnings
[poolifier.git] / rollup.config.mjs
1 import terser from '@rollup/plugin-terser'
2 import typescript from '@rollup/plugin-typescript'
3 import analyze from 'rollup-plugin-analyzer'
4 import command from 'rollup-plugin-command'
5 import del from 'rollup-plugin-delete'
6
7 const isDevelopmentBuild = process.env.BUILD === 'development'
8 const isAnalyze = process.env.ANALYZE
9 const isDocumentation = process.env.DOCUMENTATION
10
11 export default {
12 input: 'src/index.ts',
13 output: {
14 ...(isDevelopmentBuild ? { dir: 'lib' } : { file: 'lib/index.js' }),
15 format: 'cjs',
16 sourcemap: !!isDevelopmentBuild,
17 ...(isDevelopmentBuild && { preserveModules: true }),
18 ...(isDevelopmentBuild && { preserveModulesRoot: 'src' }),
19 ...(!isDevelopmentBuild && { plugins: [terser({ maxWorkers: 2 })] })
20 },
21 external: ['async_hooks', 'cluster', 'events', 'os', 'worker_threads'],
22 plugins: [
23 typescript({
24 tsconfig: isDevelopmentBuild
25 ? 'tsconfig.development.json'
26 : 'tsconfig.production.json'
27 }),
28 del({
29 targets: ['lib/*']
30 }),
31 isAnalyze && analyze(),
32 isDocumentation && command('npm run typedoc')
33 ]
34 }