2018-11-28 12:03:28 +01:00
|
|
|
'use strict'
|
|
|
|
|
2022-09-20 07:09:14 +02:00
|
|
|
const path = require('node:path')
|
2020-05-26 05:14:12 +02:00
|
|
|
const { babel } = require('@rollup/plugin-babel')
|
2020-07-07 09:23:11 +02:00
|
|
|
const { nodeResolve } = require('@rollup/plugin-node-resolve')
|
2020-06-19 10:17:01 +02:00
|
|
|
const replace = require('@rollup/plugin-replace')
|
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
|
|
|
|
2021-10-29 09:38:35 +02:00
|
|
|
let fileDestination = `bootstrap${ESM ? '.esm' : ''}`
|
2020-06-19 10:17:01 +02:00
|
|
|
const external = ['@popperjs/core']
|
2017-08-29 21:16:00 +02:00
|
|
|
const plugins = [
|
2019-04-15 10:40:49 +02:00
|
|
|
babel({
|
2020-12-02 07:30:35 +01:00
|
|
|
// Only transpile our source code
|
2019-04-15 10:40:49 +02:00
|
|
|
exclude: 'node_modules/**',
|
2020-05-26 05:14:12 +02:00
|
|
|
// Include the helpers in the bundle, at most one copy of each
|
|
|
|
babelHelpers: 'bundled'
|
2019-04-15 10:40:49 +02:00
|
|
|
})
|
2017-08-29 21:16:00 +02:00
|
|
|
]
|
|
|
|
const globals = {
|
2020-06-19 10:17:01 +02:00
|
|
|
'@popperjs/core': 'Popper'
|
2017-08-29 21:16:00 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
if (BUNDLE) {
|
2021-10-29 09:38:35 +02:00
|
|
|
fileDestination += '.bundle'
|
2018-10-14 13:59:51 +02:00
|
|
|
// Remove last entry in external array to bundle Popper
|
|
|
|
external.pop()
|
2020-06-19 10:17:01 +02:00
|
|
|
delete globals['@popperjs/core']
|
2021-03-10 17:47:42 +01:00
|
|
|
plugins.push(
|
|
|
|
replace({
|
|
|
|
'process.env.NODE_ENV': '"production"',
|
|
|
|
preventAssignment: true
|
|
|
|
}),
|
|
|
|
nodeResolve()
|
|
|
|
)
|
2017-08-29 21:16:00 +02:00
|
|
|
}
|
|
|
|
|
2019-03-01 10:11:41 +01:00
|
|
|
const rollupConfig = {
|
2019-03-01 23:50:31 +01:00
|
|
|
input: path.resolve(__dirname, `../js/index.${ESM ? 'esm' : 'umd'}.js`),
|
2017-08-29 21:16:00 +02:00
|
|
|
output: {
|
2022-11-09 10:36:12 +01:00
|
|
|
banner: banner(),
|
2021-10-29 09:38:35 +02:00
|
|
|
file: path.resolve(__dirname, `../dist/js/${fileDestination}.js`),
|
2019-03-01 10:11:41 +01:00
|
|
|
format: ESM ? 'esm' : 'umd',
|
2021-10-04 18:46:07 +02:00
|
|
|
globals,
|
|
|
|
generatedCode: 'es2015'
|
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
|