rollup.config.js 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273
  1. import glob from 'glob'
  2. import babel from 'rollup-plugin-babel'
  3. import resolve from 'rollup-plugin-node-resolve'
  4. import commonjs from 'rollup-plugin-commonjs'
  5. import minify from 'rollup-plugin-babel-minify'
  6. import inject from 'rollup-plugin-inject'
  7. import multiEntry from 'rollup-plugin-multi-entry'
  8. const files = glob.sync('src/**/*.js', {
  9. ignore: ['src/constants/**', 'src/utils/**', 'src/virtual-scroll/**']
  10. })
  11. const external = ['jquery']
  12. const globals = {
  13. jquery: 'jQuery'
  14. }
  15. const config = []
  16. const plugins = [
  17. inject({
  18. include: '**/*.js',
  19. exclude: 'node_modules/**',
  20. $: 'jquery'
  21. }),
  22. resolve(),
  23. commonjs(),
  24. babel({
  25. exclude: 'node_modules/**'
  26. })
  27. ]
  28. if (process.env.NODE_ENV === 'production') {
  29. plugins.push(minify({
  30. comments: false
  31. }))
  32. }
  33. for (const file of files) {
  34. let out = `dist/${file.replace('src/', '')}`
  35. if (process.env.NODE_ENV === 'production') {
  36. out = out.replace(/.js$/, '.min.js')
  37. }
  38. config.push({
  39. input: file,
  40. output: {
  41. name: 'BootstrapTable',
  42. file: out,
  43. format: 'umd',
  44. globals
  45. },
  46. external,
  47. plugins
  48. })
  49. }
  50. let out = 'dist/bootstrap-table-locale-all.js'
  51. if (process.env.NODE_ENV === 'production') {
  52. out = out.replace(/.js$/, '.min.js')
  53. }
  54. config.push({
  55. input: 'src/locale/**/*.js',
  56. output: {
  57. name: 'BootstrapTable',
  58. file: out,
  59. format: 'umd',
  60. globals
  61. },
  62. external,
  63. plugins: [
  64. multiEntry(),
  65. ...plugins
  66. ]
  67. })
  68. export default config