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