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