rollup.config.js 1.03 KB
Newer Older
1
2
'use strict'

Johann-S's avatar
Johann-S committed
3
4
5
6
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
7

8
9
const BUNDLE  = process.env.BUNDLE === 'true'

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

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

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