bootstrap/build/rollup.config.js

50 lines
1.0 KiB
JavaScript
Raw Normal View History

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