Skip to content

Commit 2658e7e

Browse files
committed
Create a bundled release of Bootstrap with Popper.js inside
1 parent e1a9f63 commit 2658e7e

File tree

18 files changed

+144
-45
lines changed

18 files changed

+144
-45
lines changed

.babelrc

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,5 @@
77
"modules": false
88
}
99
]
10-
],
11-
"plugins": [
12-
"transform-es2015-modules-strip"
1310
]
1411
}

build/rollup.config.js

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
const path = require('path')
2+
const resolve = require('rollup-plugin-node-resolve')
3+
const BUNDLE = process.env.BUNDLE === 'true'
4+
5+
var fileDest = 'bootstrap.js'
6+
var external = ['jquery', 'popper.js']
7+
const plugins = []
8+
const globals = {
9+
jquery: '$',
10+
'popper.js': 'Popper'
11+
}
12+
13+
if (BUNDLE) {
14+
fileDest = 'bootstrap.bundle.js'
15+
// remove last entry in external array ton bundle Popper
16+
external.pop()
17+
delete globals['popper.js']
18+
plugins.push(resolve())
19+
}
20+
21+
module.exports = {
22+
input: path.resolve(__dirname, '../js/src/index.js'),
23+
output: {
24+
file: path.resolve(__dirname, `../dist/js/${fileDest}`),
25+
format: 'iife'
26+
},
27+
name: 'bootstrap',
28+
external: external,
29+
globals: globals,
30+
plugins: plugins
31+
}

build/stamp.js

Lines changed: 11 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,14 @@
1-
const fs = require('fs')
1+
const fs = require('fs')
2+
const path = require('path')
3+
const pkg = require(path.resolve(__dirname, '../package.json'))
4+
const year = new Date().getFullYear()
25

3-
fs.readFile('package.json', (err, data) => {
4-
if (err) {
5-
throw err
6-
}
7-
8-
const pkg = JSON.parse(data)
9-
const year = new Date().getFullYear()
6+
const pathBoostrap = path.resolve(__dirname, '../dist/js/bootstrap.js')
7+
const pathBootstrapBundle = path.resolve(__dirname, '../dist/js/bootstrap.bundle.js')
8+
const contentFile = fs.readFileSync(pathBoostrap, { encoding: 'UTF8' })
9+
const contentBundleFile = fs.readFileSync(pathBootstrapBundle, { encoding: 'UTF8' })
1010

11-
const stampTop =
11+
const stamp =
1212
`/*!
1313
* Bootstrap v${pkg.version} (${pkg.homepage})
1414
* Copyright 2011-${year} ${pkg.author}
@@ -25,17 +25,6 @@ if (typeof jQuery === 'undefined') {
2525
throw new Error('Bootstrap\\'s JavaScript requires at least jQuery v3.0.0 but less than v4.0.0')
2626
}
2727
})(jQuery);
28-
29-
(function () {
3028
`
31-
const stampEnd = `
32-
})();`
33-
34-
process.stdout.write(stampTop)
35-
36-
process.stdin.on('end', () => {
37-
process.stdout.write(stampEnd)
38-
})
39-
40-
process.stdin.pipe(process.stdout)
41-
})
29+
fs.writeFileSync(pathBoostrap, `${stamp}${contentFile}`, { encoding: 'UTF8' })
30+
fs.writeFileSync(pathBootstrapBundle, `${stamp}${contentBundleFile}`, { encoding: 'UTF8' })

js/src/alert.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import $ from 'jquery'
12
import Util from './util'
23

34

@@ -8,7 +9,7 @@ import Util from './util'
89
* --------------------------------------------------------------------------
910
*/
1011

11-
const Alert = (($) => {
12+
const Alert = (() => {
1213

1314

1415
/**

js/src/button.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,12 @@
1+
import $ from 'jquery'
12
/**
23
* --------------------------------------------------------------------------
34
* Bootstrap (v4.0.0-beta): button.js
45
* Licensed under MIT (https://github.com/twbs/bootstrap/blob/master/LICENSE)
56
* --------------------------------------------------------------------------
67
*/
78

8-
const Button = (($) => {
9+
const Button = (() => {
910

1011

1112
/**

js/src/carousel.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import $ from 'jquery'
12
import Util from './util'
23

34

@@ -8,7 +9,7 @@ import Util from './util'
89
* --------------------------------------------------------------------------
910
*/
1011

11-
const Carousel = (($) => {
12+
const Carousel = (() => {
1213

1314

1415
/**

js/src/collapse.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import $ from 'jquery'
12
import Util from './util'
23

34

@@ -8,7 +9,7 @@ import Util from './util'
89
* --------------------------------------------------------------------------
910
*/
1011

11-
const Collapse = (($) => {
12+
const Collapse = (() => {
1213

1314

1415
/**

js/src/dropdown.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
/* global Popper */
2-
1+
import $ from 'jquery'
2+
import Popper from 'popper.js'
33
import Util from './util'
44

55

@@ -10,7 +10,7 @@ import Util from './util'
1010
* --------------------------------------------------------------------------
1111
*/
1212

13-
const Dropdown = (($) => {
13+
const Dropdown = (() => {
1414

1515
/**
1616
* Check for Popper dependency
@@ -445,6 +445,6 @@ const Dropdown = (($) => {
445445

446446
return Dropdown
447447

448-
})(jQuery)
448+
})(jQuery, Popper)
449449

450450
export default Dropdown

js/src/index.js

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
import Alert from './alert'
2+
import Button from './button'
3+
import Carousel from './carousel'
4+
import Collapse from './collapse'
5+
import Dropdown from './dropdown'
6+
import Modal from './modal'
7+
import Popover from './popover'
8+
import Scrollspy from './scrollspy'
9+
import Tab from './tab'
10+
import Tooltip from './tooltip'
11+
import Util from './util'
12+
13+
/**
14+
* --------------------------------------------------------------------------
15+
* Bootstrap (v4.0.0-alpha.6): index.js
16+
* Licensed under MIT (https://github.com/twbs/bootstrap/blob/master/LICENSE)
17+
* --------------------------------------------------------------------------
18+
*/
19+
20+
export {
21+
Util,
22+
Alert,
23+
Button,
24+
Carousel,
25+
Collapse,
26+
Dropdown,
27+
Modal,
28+
Popover,
29+
Scrollspy,
30+
Tab,
31+
Tooltip
32+
}

js/src/modal.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import $ from 'jquery'
12
import Util from './util'
23

34

@@ -8,7 +9,7 @@ import Util from './util'
89
* --------------------------------------------------------------------------
910
*/
1011

11-
const Modal = (($) => {
12+
const Modal = (() => {
1213

1314

1415
/**

0 commit comments

Comments
 (0)