twbs--bootstrap/build/rollup.config.js

56 lines
1.2 KiB
JavaScript
Raw Normal View History

'use strict'
2019-02-26 11:20:34 +00:00
const path = require('path')
const babel = require('rollup-plugin-babel')
2018-10-14 11:59:51 +00:00
const resolve = require('rollup-plugin-node-resolve')
2019-02-26 11:20:34 +00:00
const banner = require('./banner.js')
2017-12-16 12:00:38 +00:00
2019-02-26 11:20:34 +00:00
const BUNDLE = process.env.BUNDLE === 'true'
2019-03-01 09:11:41 +00:00
const ESM = process.env.ESM === 'true'
2019-03-01 22:50:31 +00:00
let fileDest = `bootstrap${ESM ? '.esm' : ''}`
2018-09-14 12:27:30 +00:00
const external = ['popper.js']
const plugins = [
babel({
// Only transpile our source code
exclude: 'node_modules/**',
// Include only required helpers
externalHelpersWhitelist: [
'defineProperties',
'createClass',
'inheritsLoose',
'defineProperty',
'objectSpread'
]
})
]
const globals = {
'popper.js': 'Popper'
}
if (BUNDLE) {
2019-03-01 22:50:31 +00:00
fileDest += '.bundle'
2018-10-14 11:59:51 +00:00
// Remove last entry in external array to bundle Popper
external.pop()
delete globals['popper.js']
2018-10-14 11:59:51 +00:00
plugins.push(resolve())
}
2019-03-01 09:11:41 +00:00
const rollupConfig = {
2019-03-01 22:50:31 +00:00
input: path.resolve(__dirname, `../js/index.${ESM ? 'esm' : 'umd'}.js`),
output: {
banner,
2019-03-01 22:50:31 +00:00
file: path.resolve(__dirname, `../dist/js/${fileDest}.js`),
2019-03-01 09:11:41 +00:00
format: ESM ? 'esm' : 'umd',
globals
},
external,
plugins
}
2019-03-01 09:11:41 +00:00
if (!ESM) {
rollupConfig.output.name = 'bootstrap'
}
module.exports = rollupConfig