Switch forEach loop to for of syntax
[poolifier.git] / rollup.config.mjs
CommitLineData
f45e4999 1import analyze from 'rollup-plugin-analyzer'
5ea22628 2import command from 'rollup-plugin-command'
eae1fc25 3import del from 'rollup-plugin-delete'
eae1fc25
JB
4import { terser } from 'rollup-plugin-terser'
5import ts from 'rollup-plugin-ts'
660940b0
JB
6
7const isDevelopmentBuild = process.env.BUILD === 'development'
f4162974 8const isAnalyze = process.env.ANALYZE
5ea22628 9const isDocumentation = process.env.DOCUMENTATION
660940b0
JB
10
11export default {
12 input: 'src/index.ts',
f4162974
JB
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({ numWorkers: 2 })] })
20 },
23ff945a 21 external: ['async_hooks', 'cluster', 'events', 'os', 'worker_threads'],
660940b0 22 plugins: [
61a90f2e 23 ts({
660940b0
JB
24 tsconfig: isDevelopmentBuild
25 ? 'tsconfig.development.json'
61a90f2e
JB
26 : 'tsconfig.json',
27 browserslist: false
660940b0
JB
28 }),
29 del({
f4162974 30 targets: ['lib/*']
f45e4999 31 }),
5ea22628
JB
32 isAnalyze && analyze(),
33 isDocumentation && command('npm run typedoc')
660940b0
JB
34 ]
35}