X-Git-Url: https://git.piment-noir.org/?a=blobdiff_plain;f=rollup.config.mjs;h=77d516bd6e483da4c5cac72391b3a05cb1bb4087;hb=83f518ffe91a8490b3380f9f647b102869798bcb;hp=d35b8c42a00cea7e12e5eaf36f5d1733d048a374;hpb=7977150f9030ac200bd87f2f9f4752fa4de14581;p=poolifier.git diff --git a/rollup.config.mjs b/rollup.config.mjs index d35b8c42..77d516bd 100644 --- a/rollup.config.mjs +++ b/rollup.config.mjs @@ -1,16 +1,22 @@ import typescript from 'rollup-plugin-typescript2' +import analyze from 'rollup-plugin-analyzer' +import { terser } from 'rollup-plugin-terser' import del from 'rollup-plugin-delete' +import command from 'rollup-plugin-command' const isDevelopmentBuild = process.env.BUILD === 'development' +const isAnalyze = process.env.ANALYZE +const isDocumentation = process.env.DOCUMENTATION export default { input: 'src/index.ts', output: { - dir: 'lib', + ...(isDevelopmentBuild ? { dir: 'lib' } : { file: 'lib/index.js' }), format: 'cjs', sourcemap: !!isDevelopmentBuild, - preserveModules: true, - preserveModulesRoot: 'src' + ...(isDevelopmentBuild && { preserveModules: true }), + ...(isDevelopmentBuild && { preserveModulesRoot: 'src' }), + ...(!isDevelopmentBuild && { plugins: [terser({ numWorkers: 2 })] }) }, external: ['async_hooks', 'cluster', 'events', 'worker_threads'], plugins: [ @@ -20,7 +26,9 @@ export default { : 'tsconfig.json' }), del({ - targets: 'lib/*' - }) + targets: ['lib/*'] + }), + isAnalyze && analyze(), + isDocumentation && command('npm run typedoc') ] }