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 { terser } from 'rollup-plugin-terser'
|
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(terser({
|
38 | output: {
|
39 | comments () {
|
40 | return false
|
41 | }
|
42 | }
|
43 | }))
|
44 | }
|
45 |
|
46 | for (const file of files) {
|
47 | let out = `dist/${file.replace('src/', '')}`
|
48 | if (process.env.NODE_ENV === 'production') {
|
49 | out = out.replace(/.js$/, '.min.js')
|
50 | }
|
51 | config.push({
|
52 | input: file,
|
53 | output: {
|
54 | name: 'BootstrapTable',
|
55 | file: out,
|
56 | format: 'umd',
|
57 | globals
|
58 | },
|
59 | external,
|
60 | plugins
|
61 | })
|
62 | }
|
63 |
|
64 | let out = 'dist/bootstrap-table-locale-all.js'
|
65 | if (process.env.NODE_ENV === 'production') {
|
66 | out = out.replace(/.js$/, '.min.js')
|
67 | }
|
68 | config.push({
|
69 | input: 'src/locale/**/*.js',
|
70 | output: {
|
71 | name: 'BootstrapTable',
|
72 | file: out,
|
73 | format: 'umd',
|
74 | globals
|
75 | },
|
76 | external,
|
77 | plugins: [
|
78 | multiEntry(),
|
79 | ...plugins
|
80 | ]
|
81 | })
|
82 |
|
83 | out = 'dist/bootstrap-table-vue.js'
|
84 | if (process.env.NODE_ENV === 'production') {
|
85 | out = out.replace(/.js$/, '.min.js')
|
86 | }
|
87 | config.push({
|
88 | input: 'src/vue/index.js',
|
89 | output: {
|
90 | name: 'BootstrapTable',
|
91 | file: out,
|
92 | format: 'umd'
|
93 | },
|
94 | plugins: [
|
95 | vue(),
|
96 | ...plugins
|
97 | ]
|
98 | })
|
99 |
|
100 | out = 'dist/bootstrap-table-vue.esm.js'
|
101 | if (process.env.NODE_ENV === 'production') {
|
102 | out = out.replace(/.js$/, '.min.js')
|
103 | }
|
104 | config.push({
|
105 | input: 'src/vue/BootstrapTable.vue',
|
106 | output: {
|
107 | name: 'BootstrapTable',
|
108 | file: out,
|
109 | format: 'esm'
|
110 | },
|
111 | plugins: [
|
112 | vue(),
|
113 | ...plugins
|
114 | ]
|
115 | })
|
116 |
|
117 | export default config
|