Apply dependencies update (#482)
[poolifier.git] / rollup.config.mjs
index 8afbc006de8827bccd162a14d2d3a1d4e33de695..f301a0871b09c655762b1ceee7495a9fa2af8dc3 100644 (file)
@@ -2,26 +2,23 @@ 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'
+import istanbul from 'rollup-plugin-istanbul'
 
 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',
-      format: 'cjs',
-      sourcemap: !!isDevelopmentBuild,
-      preserveModules: true,
-      preserveModulesRoot: 'src'
-    },
-    isDevelopmentBuild && {
-      file: 'lib.min/index.js',
-      format: 'cjs',
-      sourcemap: !!isDevelopmentBuild,
-      plugins: [terser({ numWorkers: 2 })]
-    }
-  ],
+  output: {
+    ...(isDevelopmentBuild ? { dir: 'lib' } : { file: 'lib/index.js' }),
+    format: 'cjs',
+    sourcemap: !!isDevelopmentBuild,
+    ...(isDevelopmentBuild && { preserveModules: true }),
+    ...(isDevelopmentBuild && { preserveModulesRoot: 'src' }),
+    ...(!isDevelopmentBuild && { plugins: [terser({ numWorkers: 2 })] })
+  },
   external: ['async_hooks', 'cluster', 'events', 'worker_threads'],
   plugins: [
     typescript({
@@ -29,9 +26,11 @@ export default {
         ? 'tsconfig.development.json'
         : 'tsconfig.json'
     }),
+    isDevelopmentBuild && istanbul(),
     del({
-      targets: ['lib/*', 'lib.min/*']
+      targets: ['lib/*']
     }),
-    isDevelopmentBuild && analyze()
+    isAnalyze && analyze(),
+    isDocumentation && command('npm run typedoc')
   ]
 }