Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 13 additions & 0 deletions build/banner.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
const path = require('path')
const pkg = require(path.resolve(__dirname, '../package.json'))
const year = new Date().getFullYear()

function getBanner(pluginFilename) {
return `/*!
* Bootstrap${pluginFilename ? ` ${pluginFilename}` : ''} v${pkg.version} (${pkg.homepage})
* Copyright 2011-${year} ${pkg.author}
* Licensed under MIT (https://github.com/twbs/bootstrap/blob/master/LICENSE)
*/`
}

module.exports = getBanner
6 changes: 5 additions & 1 deletion build/build-plugins.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
const rollup = require('rollup')
const path = require('path')
const babel = require('rollup-plugin-babel')
const banner = require('./banner.js')
const TEST = process.env.NODE_ENV === 'test'

const plugins = [
Expand Down Expand Up @@ -61,17 +62,20 @@ Object.keys(bsPlugins)
globals[bsPlugins.Tooltip] = 'Tooltip'
}

const pluginFilename = `${pluginKey.toLowerCase()}.js`

rollup.rollup({
input: bsPlugins[pluginKey],
plugins,
external
}).then((bundle) => {
bundle.write({
banner: banner(pluginFilename),
format,
name: pluginKey,
sourcemap: true,
globals,
file: path.resolve(__dirname, `${rootPath}${pluginKey.toLowerCase()}.js`)
file: path.resolve(__dirname, `${rootPath}${pluginFilename}`)
})
.then(() => console.log(`Building ${pluginKey} plugin... Done!`))
.catch((err) => console.error(`${pluginKey}: ${err}`))
Expand Down
9 changes: 2 additions & 7 deletions build/rollup.config.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
const path = require('path')
const babel = require('rollup-plugin-babel')
const resolve = require('rollup-plugin-node-resolve')
const banner = require('./banner.js')

const pkg = require(path.resolve(__dirname, '../package.json'))
const BUNDLE = process.env.BUNDLE === 'true'
const year = new Date().getFullYear()

let fileDest = 'bootstrap.js'
const external = ['jquery', 'popper.js']
Expand Down Expand Up @@ -36,11 +35,7 @@ if (BUNDLE) {
module.exports = {
input: path.resolve(__dirname, '../js/src/index.js'),
output: {
banner: `/*!
* Bootstrap v${pkg.version} (${pkg.homepage})
* Copyright 2011-${year} ${pkg.author}
* Licensed under MIT (https://github.com/twbs/bootstrap/blob/master/LICENSE)
*/`,
banner,
file: path.resolve(__dirname, `../dist/js/${fileDest}`),
format: 'umd',
globals,
Expand Down