UNPKG

2.36 kBJavaScriptView Raw
1import glob from 'glob'
2import babel from 'rollup-plugin-babel'
3import resolve from 'rollup-plugin-node-resolve'
4import commonjs from 'rollup-plugin-commonjs'
5import { terser } from 'rollup-plugin-terser'
6import inject from 'rollup-plugin-inject'
7import copy from 'rollup-plugin-copy'
8import multiEntry from 'rollup-plugin-multi-entry'
9import vue from 'rollup-plugin-vue'
10
11const files = glob.sync('src/**/*.js', {
12 ignore: [
13 'src/constants/**',
14 'src/utils/**',
15 'src/virtual-scroll/**',
16 'src/vue/**'
17 ]
18})
19const external = ['jquery']
20const globals = {
21 jquery: 'jQuery'
22}
23const config = []
24const plugins = [
25 inject({
26 include: '**/*.js',
27 exclude: 'node_modules/**',
28 $: 'jquery'
29 }),
30 resolve(),
31 commonjs(),
32 babel({
33 exclude: 'node_modules/**'
34 }),
35 copy({
36 targets: [
37 { src: 'src/themes/bootstrap-table/fonts/*', dest: 'dist/themes/bootstrap-table/fonts' }
38 ]
39 })
40]
41
42if (process.env.NODE_ENV === 'production') {
43 plugins.push(terser({
44 output: {
45 comments () {
46 return false
47 }
48 }
49 }))
50}
51
52for (const file of files) {
53 let out = `dist/${file.replace('src/', '')}`
54 if (process.env.NODE_ENV === 'production') {
55 out = out.replace(/.js$/, '.min.js')
56 }
57 config.push({
58 input: file,
59 output: {
60 name: 'BootstrapTable',
61 file: out,
62 format: 'umd',
63 globals
64 },
65 external,
66 plugins
67 })
68}
69
70let out = 'dist/bootstrap-table-locale-all.js'
71if (process.env.NODE_ENV === 'production') {
72 out = out.replace(/.js$/, '.min.js')
73}
74config.push({
75 input: 'src/locale/**/*.js',
76 output: {
77 name: 'BootstrapTable',
78 file: out,
79 format: 'umd',
80 globals
81 },
82 external,
83 plugins: [
84 multiEntry(),
85 ...plugins
86 ]
87})
88
89out = 'dist/bootstrap-table-vue.js'
90if (process.env.NODE_ENV === 'production') {
91 out = out.replace(/.js$/, '.min.js')
92}
93config.push({
94 input: 'src/vue/index.js',
95 output: {
96 name: 'BootstrapTable',
97 file: out,
98 format: 'umd'
99 },
100 plugins: [
101 vue(),
102 ...plugins
103 ]
104})
105
106out = 'dist/bootstrap-table-vue.esm.js'
107if (process.env.NODE_ENV === 'production') {
108 out = out.replace(/.js$/, '.min.js')
109}
110config.push({
111 input: 'src/vue/BootstrapTable.vue',
112 output: {
113 name: 'BootstrapTable',
114 file: out,
115 format: 'esm'
116 },
117 plugins: [
118 vue(),
119 ...plugins
120 ]
121})
122
123export default config