diff options
Diffstat (limited to 'vendor/twbs/bootstrap/build/rollup.config.js')
-rw-r--r-- | vendor/twbs/bootstrap/build/rollup.config.js | 37 |
1 files changed, 25 insertions, 12 deletions
diff --git a/vendor/twbs/bootstrap/build/rollup.config.js b/vendor/twbs/bootstrap/build/rollup.config.js index e2d2b125e..c00438de2 100644 --- a/vendor/twbs/bootstrap/build/rollup.config.js +++ b/vendor/twbs/bootstrap/build/rollup.config.js @@ -3,12 +3,14 @@ const path = require('path') const { babel } = require('@rollup/plugin-babel') const { nodeResolve } = require('@rollup/plugin-node-resolve') +const replace = require('@rollup/plugin-replace') const banner = require('./banner.js') const BUNDLE = process.env.BUNDLE === 'true' +const ESM = process.env.ESM === 'true' -let fileDest = 'bootstrap.js' -const external = ['jquery', 'popper.js'] +let fileDest = `bootstrap${ESM ? '.esm' : ''}` +const external = ['@popperjs/core'] const plugins = [ babel({ // Only transpile our source code @@ -18,27 +20,38 @@ const plugins = [ }) ] const globals = { - jquery: 'jQuery', // Ensure we use jQuery which is always available even in noConflict mode - 'popper.js': 'Popper' + '@popperjs/core': 'Popper' } if (BUNDLE) { - fileDest = 'bootstrap.bundle.js' + fileDest += '.bundle' // Remove last entry in external array to bundle Popper external.pop() - delete globals['popper.js'] - plugins.push(nodeResolve()) + delete globals['@popperjs/core'] + plugins.push( + replace({ + 'process.env.NODE_ENV': '"production"', + preventAssignment: true + }), + nodeResolve() + ) } -module.exports = { - input: path.resolve(__dirname, '../js/index.js'), +const rollupConfig = { + input: path.resolve(__dirname, `../js/index.${ESM ? 'esm' : 'umd'}.js`), output: { banner, - file: path.resolve(__dirname, `../dist/js/${fileDest}`), - format: 'umd', + file: path.resolve(__dirname, `../dist/js/${fileDest}.js`), + format: ESM ? 'esm' : 'umd', globals, - name: 'bootstrap' + generatedCode: 'es2015' }, external, plugins } + +if (!ESM) { + rollupConfig.output.name = 'bootstrap' +} + +module.exports = rollupConfig |