1
0
Fork 0
mirror of https://github.com/twbs/bootstrap.git synced 2022-11-09 12:25:43 -05:00
twbs--bootstrap/build/rollup.config.js

51 lines
1.2 KiB
JavaScript
Raw Normal View History

'use strict'
2019-02-26 06:20:34 -05:00
const path = require('path')
const { babel } = require('@rollup/plugin-babel')
const { nodeResolve } = require('@rollup/plugin-node-resolve')
2020-06-19 04:17:01 -04:00
const replace = require('@rollup/plugin-replace')
2019-02-26 06:20:34 -05:00
const banner = require('./banner.js')
2017-12-16 07:00:38 -05:00
2019-02-26 06:20:34 -05:00
const BUNDLE = process.env.BUNDLE === 'true'
2019-03-01 04:11:41 -05:00
const ESM = process.env.ESM === 'true'
2019-03-01 17:50:31 -05:00
let fileDest = `bootstrap${ESM ? '.esm' : ''}`
2020-06-19 04:17:01 -04:00
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 = {
2020-06-19 04:17:01 -04:00
'@popperjs/core': 'Popper'
}
if (BUNDLE) {
2019-03-01 17:50:31 -05:00
fileDest += '.bundle'
2018-10-14 07:59:51 -04:00
// Remove last entry in external array to bundle Popper
external.pop()
2020-06-19 04:17:01 -04:00
delete globals['@popperjs/core']
plugins.push(replace({ 'process.env.NODE_ENV': '"production"' }), nodeResolve())
}
2019-03-01 04:11:41 -05:00
const rollupConfig = {
2019-03-01 17:50:31 -05:00
input: path.resolve(__dirname, `../js/index.${ESM ? 'esm' : 'umd'}.js`),
output: {
banner,
2019-03-01 17:50:31 -05:00
file: path.resolve(__dirname, `../dist/js/${fileDest}.js`),
2019-03-01 04:11:41 -05:00
format: ESM ? 'esm' : 'umd',
globals
},
external,
plugins
}
2019-03-01 04:11:41 -05:00
if (!ESM) {
rollupConfig.output.name = 'bootstrap'
}
module.exports = rollupConfig