build: refactor build options handling
authorJérôme Benoit <jerome.benoit@sap.com>
Sun, 28 May 2023 11:11:46 +0000 (13:11 +0200)
committerJérôme Benoit <jerome.benoit@sap.com>
Sun, 28 May 2023 11:11:46 +0000 (13:11 +0200)
Signed-off-by: Jérôme Benoit <jerome.benoit@sap.com>
rollup.config.mjs

index 02fc54c00e9f514e30134078d69b56a41a971c29..99f833b4108e3f5b799b0310eef99d10ddde4122 100644 (file)
@@ -13,25 +13,31 @@ export default {
   strictDeprecations: true,
   output: [
     {
-      ...(isDevelopmentBuild ? { dir: 'lib' } : { file: 'lib/index.js' }),
       format: 'cjs',
       sourcemap: !!isDevelopmentBuild,
       ...(isDevelopmentBuild && {
+        dir: 'lib',
         preserveModules: true,
         preserveModulesRoot: 'src'
       }),
-      ...(!isDevelopmentBuild && { plugins: [terser({ maxWorkers: 2 })] })
+      ...(!isDevelopmentBuild && {
+        file: 'lib/index.js',
+        plugins: [terser({ maxWorkers: 2 })]
+      })
     },
     {
-      ...(isDevelopmentBuild ? { dir: 'lib' } : { file: 'lib/index.mjs' }),
       format: 'esm',
       sourcemap: !!isDevelopmentBuild,
       ...(isDevelopmentBuild && {
+        dir: 'lib',
         entryFileNames: '[name].mjs',
         preserveModules: true,
         preserveModulesRoot: 'src'
       }),
-      ...(!isDevelopmentBuild && { plugins: [terser({ maxWorkers: 2 })] })
+      ...(!isDevelopmentBuild && {
+        file: 'lib/index.mjs',
+        plugins: [terser({ maxWorkers: 2 })]
+      })
     }
   ],
   external: [