rollup.config.js 1.12 KB
Newer Older
Johann-S's avatar
Johann-S committed
1
2
3
4
const path    = require('path')
const babel   = require('rollup-plugin-babel')
const resolve = require('rollup-plugin-node-resolve')
const banner  = require('./banner.js')
XhmikosR's avatar
XhmikosR committed
5

6
7
const BUNDLE  = process.env.BUNDLE === 'true'

Johann-S's avatar
Johann-S committed
8
9
let fileDest  = 'bootstrap.js'
const external = ['jquery', 'popper.js']
10
11
const plugins = [
  babel({
XhmikosR's avatar
XhmikosR committed
12
13
    exclude: 'node_modules/**', // Only transpile our source code
    externalHelpersWhitelist: [ // Include only required helpers
Henry Zhu's avatar
Henry Zhu committed
14
      'defineProperties',
15
      'createClass',
16
      'inheritsLoose',
17
      'defineProperty',
Johann-S's avatar
Johann-S committed
18
      'objectSpread'
19
20
21
22
    ]
  })
]
const globals = {
XhmikosR's avatar
XhmikosR committed
23
  jquery: 'jQuery', // Ensure we use jQuery which is always available even in noConflict mode
24
25
26
27
28
  'popper.js': 'Popper'
}

if (BUNDLE) {
  fileDest = 'bootstrap.bundle.js'
Johann-S's avatar
Johann-S committed
29
30
  // Remove last entry in external array to bundle Popper
  external.pop()
31
  delete globals['popper.js']
Johann-S's avatar
Johann-S committed
32
  plugins.push(resolve())
33
34
35
36
37
}

module.exports = {
  input: path.resolve(__dirname, '../js/src/index.js'),
  output: {
38
    banner,
39
40
41
42
43
44
45
    file: path.resolve(__dirname, `../dist/js/${fileDest}`),
    format: 'umd',
    globals,
    name: 'bootstrap'
  },
  external,
  plugins
46
}