diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-07-24 09:22:02 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-07-24 09:22:02 +0000 |
commit | 8b9e5144f7af3bb0578d80ed619dd0743d0d5f0f (patch) | |
tree | c651acc917541c3ad4fc91eb30df52c2f07095fd /build/rollup.config.mjs | |
parent | Adding upstream version 5.3.1+dfsg. (diff) | |
download | bootstrap-html-8b9e5144f7af3bb0578d80ed619dd0743d0d5f0f.tar.xz bootstrap-html-8b9e5144f7af3bb0578d80ed619dd0743d0d5f0f.zip |
Adding upstream version 5.3.3+dfsg.upstream/5.3.3+dfsgupstream
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'build/rollup.config.mjs')
-rw-r--r-- | build/rollup.config.mjs | 59 |
1 files changed, 59 insertions, 0 deletions
diff --git a/build/rollup.config.mjs b/build/rollup.config.mjs new file mode 100644 index 0000000..dd6c7d1 --- /dev/null +++ b/build/rollup.config.mjs @@ -0,0 +1,59 @@ +import path from 'node:path' +import process from 'node:process' +import { fileURLToPath } from 'node:url' +import { babel } from '@rollup/plugin-babel' +import { nodeResolve } from '@rollup/plugin-node-resolve' +import replace from '@rollup/plugin-replace' +import banner from './banner.mjs' + +const __dirname = path.dirname(fileURLToPath(import.meta.url)) + +const BUNDLE = process.env.BUNDLE === 'true' +const ESM = process.env.ESM === 'true' + +let destinationFile = `bootstrap${ESM ? '.esm' : ''}` +const external = ['@popperjs/core'] +const plugins = [ + babel({ + // Only transpile our source code + exclude: 'node_modules/**', + // Include the helpers in the bundle, at most one copy of each + babelHelpers: 'bundled' + }) +] +const globals = { + '@popperjs/core': 'Popper' +} + +if (BUNDLE) { + destinationFile += '.bundle' + // Remove last entry in external array to bundle Popper + external.pop() + delete globals['@popperjs/core'] + plugins.push( + replace({ + 'process.env.NODE_ENV': '"production"', + preventAssignment: true + }), + nodeResolve() + ) +} + +const rollupConfig = { + input: path.resolve(__dirname, `../js/index.${ESM ? 'esm' : 'umd'}.js`), + output: { + banner: banner(), + file: path.resolve(__dirname, `../dist/js/${destinationFile}.js`), + format: ESM ? 'esm' : 'umd', + globals, + generatedCode: 'es2015' + }, + external, + plugins +} + +if (!ESM) { + rollupConfig.output.name = 'bootstrap' +} + +export default rollupConfig |