Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add license headers in js/dist files #27308

Merged
merged 3 commits into from
Sep 26, 2018
Merged
Show file tree
Hide file tree
Changes from 2 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(path.resolve(__dirname, './banner.js'))
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not a big fan of using path.resolve here because require('./banner.js') will works fine 🤔

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

True, let's change it

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(path.resolve(__dirname, './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