X-Git-Url: https://git.piment-noir.org/?a=blobdiff_plain;f=rollup.config.mjs;h=3d069f7f7b0f6956ec192bb40748db09bee76a1c;hb=1a74101bf2fbbc70e65eb274499073e0d945704e;hp=29cc1f96e86610346dc42757afe07c73fae0b560;hpb=9b121f9c11621140deabb4e061d23d019fe01bb3;p=poolifier.git diff --git a/rollup.config.mjs b/rollup.config.mjs index 29cc1f96..3d069f7f 100644 --- a/rollup.config.mjs +++ b/rollup.config.mjs @@ -1,4 +1,5 @@ import * as os from 'node:os' +import { env } from 'node:process' import { dts } from 'rollup-plugin-dts' import terser from '@rollup/plugin-terser' import typescript from '@rollup/plugin-typescript' @@ -20,9 +21,10 @@ const availableParallelism = () => { return availableParallelism } -const isDevelopmentBuild = process.env.BUILD === 'development' -const isAnalyzeBuild = process.env.ANALYZE -const isDocumentationBuild = process.env.DOCUMENTATION +const isDevelopmentBuild = env.BUILD === 'development' +const isAnalyzeBuild = env.ANALYZE +const isDocumentationBuild = env.DOCUMENTATION +const sourcemap = env.SOURCEMAP !== 'false' const maxWorkers = Math.floor(availableParallelism() / 2) @@ -35,27 +37,32 @@ export default defineConfig([ format: 'cjs', ...(isDevelopmentBuild && { dir: './lib', - sourcemap: true, preserveModules: true, preserveModulesRoot: './src' }), ...(!isDevelopmentBuild && { file: './lib/index.js', plugins: [terser({ maxWorkers })] + }), + ...(sourcemap && { + sourcemap }) }, { format: 'esm', ...(isDevelopmentBuild && { dir: './lib', - sourcemap: true, entryFileNames: '[name].mjs', + chunkFileNames: '[name]-[hash].mjs', preserveModules: true, preserveModulesRoot: './src' }), ...(!isDevelopmentBuild && { file: './lib/index.mjs', plugins: [terser({ maxWorkers })] + }), + ...(sourcemap && { + sourcemap }) } ], @@ -71,9 +78,7 @@ export default defineConfig([ ], plugins: [ typescript({ - tsconfig: isDevelopmentBuild - ? './tsconfig.development.json' - : './tsconfig.production.json' + tsconfig: './tsconfig.build.json' }), del({ targets: ['./lib/*']