2018-11-28 06:03:28 -05:00
|
|
|
'use strict'
|
|
|
|
|
2019-02-26 06:20:34 -05:00
|
|
|
const path = require('path')
|
|
|
|
const babel = require('rollup-plugin-babel')
|
2019-12-25 14:36:22 -05:00
|
|
|
const resolve = require('@rollup/plugin-node-resolve')
|
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'
|
2017-08-29 15:16:00 -04:00
|
|
|
|
2019-03-01 17:50:31 -05:00
|
|
|
let fileDest = `bootstrap${ESM ? '.esm' : ''}`
|
2018-09-14 08:27:30 -04:00
|
|
|
const external = ['popper.js']
|
2017-08-29 15:16:00 -04:00
|
|
|
const plugins = [
|
2019-04-15 04:40:49 -04:00
|
|
|
babel({
|
|
|
|
// Only transpile our source code
|
|
|
|
exclude: 'node_modules/**',
|
|
|
|
// Include only required helpers
|
|
|
|
externalHelpersWhitelist: [
|
|
|
|
'createClass',
|
2020-03-24 09:53:24 -04:00
|
|
|
'createSuper',
|
|
|
|
'defineProperties',
|
2019-04-15 04:40:49 -04:00
|
|
|
'defineProperty',
|
2020-03-24 09:53:24 -04:00
|
|
|
'getPrototypeOf',
|
|
|
|
'inheritsLoose',
|
2019-07-11 05:29:35 -04:00
|
|
|
'objectSpread2'
|
2019-04-15 04:40:49 -04:00
|
|
|
]
|
|
|
|
})
|
2017-08-29 15:16:00 -04:00
|
|
|
]
|
|
|
|
const globals = {
|
|
|
|
'popper.js': '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()
|
2017-08-29 15:16:00 -04:00
|
|
|
delete globals['popper.js']
|
2018-10-14 07:59:51 -04:00
|
|
|
plugins.push(resolve())
|
2017-08-29 15:16:00 -04:00
|
|
|
}
|
|
|
|
|
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`),
|
2017-08-29 15:16:00 -04:00
|
|
|
output: {
|
2018-09-25 11:55:35 -04:00
|
|
|
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
|
2017-12-30 19:03:22 -05:00
|
|
|
},
|
|
|
|
external,
|
|
|
|
plugins
|
2017-08-29 15:16:00 -04:00
|
|
|
}
|
2019-03-01 04:11:41 -05:00
|
|
|
|
|
|
|
if (!ESM) {
|
|
|
|
rollupConfig.output.name = 'bootstrap'
|
|
|
|
}
|
|
|
|
|
|
|
|
module.exports = rollupConfig
|