build(ci): ensure commit message follow conventionnal commit rules
[poolifier.git] / rollup.config.mjs
CommitLineData
8f98d75d
JB
1import terser from '@rollup/plugin-terser'
2import typescript from '@rollup/plugin-typescript'
f45e4999 3import analyze from 'rollup-plugin-analyzer'
5ea22628 4import command from 'rollup-plugin-command'
eae1fc25 5import del from 'rollup-plugin-delete'
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' }),
8f98d75d 19 ...(!isDevelopmentBuild && { plugins: [terser({ maxWorkers: 2 })] })
f4162974 20 },
23ff945a 21 external: ['async_hooks', 'cluster', 'events', 'os', 'worker_threads'],
660940b0 22 plugins: [
8f98d75d 23 typescript({
660940b0
JB
24 tsconfig: isDevelopmentBuild
25 ? 'tsconfig.development.json'
ce68dd22 26 : 'tsconfig.production.json'
660940b0
JB
27 }),
28 del({
f4162974 29 targets: ['lib/*']
f45e4999 30 }),
5ea22628
JB
31 isAnalyze && analyze(),
32 isDocumentation && command('npm run typedoc')
660940b0
JB
33 ]
34}