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