From 5119cf1a3864eaadb079ae68df6d4dae1a52b2cb Mon Sep 17 00:00:00 2001 From: =?utf8?q?J=C3=A9r=C3=B4me=20Benoit?= Date: Sun, 28 May 2023 13:11:46 +0200 Subject: [PATCH] build: refactor build options handling MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit Signed-off-by: Jérôme Benoit --- rollup.config.mjs | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/rollup.config.mjs b/rollup.config.mjs index 02fc54c0..99f833b4 100644 --- a/rollup.config.mjs +++ b/rollup.config.mjs @@ -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: [ -- 2.34.1