rollup.config.js 1.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  1. 'use strict'
  2. const path = require('path')
  3. const babel = require('rollup-plugin-babel')
  4. const resolve = require('rollup-plugin-node-resolve')
  5. const banner = require('./banner.js')
  6. const BUNDLE = process.env.BUNDLE === 'true'
  7. let fileDest = 'bootstrap.js'
  8. const external = ['jquery', 'popper.js']
  9. const plugins = [
  10. babel({
  11. exclude: 'node_modules/**', // Only transpile our source code
  12. externalHelpersWhitelist: [ // Include only required helpers
  13. 'defineProperties',
  14. 'createClass',
  15. 'inheritsLoose',
  16. 'defineProperty',
  17. 'objectSpread'
  18. ]
  19. })
  20. ]
  21. const globals = {
  22. jquery: 'jQuery', // Ensure we use jQuery which is always available even in noConflict mode
  23. 'popper.js': 'Popper'
  24. }
  25. if (BUNDLE) {
  26. fileDest = 'bootstrap.bundle.js'
  27. // Remove last entry in external array to bundle Popper
  28. external.pop()
  29. delete globals['popper.js']
  30. plugins.push(resolve())
  31. }
  32. module.exports = {
  33. input: path.resolve(__dirname, '../js/src/index.js'),
  34. output: {
  35. banner,
  36. file: path.resolve(__dirname, `../dist/js/${fileDest}`),
  37. format: 'umd',
  38. globals,
  39. name: 'bootstrap'
  40. },
  41. external,
  42. plugins
  43. }