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 copy from 'rollup-plugin-copy'
|
8 | import multiEntry from 'rollup-plugin-multi-entry'
|
9 | import vue from 'rollup-plugin-vue'
|
10 |
|
11 | const files = glob.sync('src/**/*.js', {
|
12 | ignore: [
|
13 | 'src/constants/**',
|
14 | 'src/utils/**',
|
15 | 'src/virtual-scroll/**',
|
16 | 'src/vue/**'
|
17 | ]
|
18 | })
|
19 | const external = ['jquery']
|
20 | const globals = {
|
21 | jquery: 'jQuery'
|
22 | }
|
23 | const config = []
|
24 | const 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 |
|
42 | if (process.env.NODE_ENV === 'production') {
|
43 | plugins.push(terser({
|
44 | output: {
|
45 | comments () {
|
46 | return false
|
47 | }
|
48 | }
|
49 | }))
|
50 | }
|
51 |
|
52 | for (const file of files) {
|
53 | let out = `dist/${file.replace('src/', '')}`
|
54 |
|
55 | if (process.env.NODE_ENV === 'production') {
|
56 | out = out.replace(/.js$/, '.min.js')
|
57 | }
|
58 | config.push({
|
59 | input: file,
|
60 | output: {
|
61 | name: 'BootstrapTable',
|
62 | file: out,
|
63 | format: 'umd',
|
64 | globals
|
65 | },
|
66 | external,
|
67 | plugins
|
68 | })
|
69 | }
|
70 |
|
71 | let out = 'dist/bootstrap-table-locale-all.js'
|
72 |
|
73 | if (process.env.NODE_ENV === 'production') {
|
74 | out = out.replace(/.js$/, '.min.js')
|
75 | }
|
76 | config.push({
|
77 | input: 'src/locale/**/*.js',
|
78 | output: {
|
79 | name: 'BootstrapTable',
|
80 | file: out,
|
81 | format: 'umd',
|
82 | globals
|
83 | },
|
84 | external,
|
85 | plugins: [
|
86 | multiEntry(),
|
87 | ...plugins
|
88 | ]
|
89 | })
|
90 |
|
91 | out = 'dist/bootstrap-table-vue.js'
|
92 | if (process.env.NODE_ENV === 'production') {
|
93 | out = out.replace(/.js$/, '.min.js')
|
94 | }
|
95 | config.push({
|
96 | input: 'src/vue/index.js',
|
97 | output: {
|
98 | name: 'BootstrapTable',
|
99 | file: out,
|
100 | format: 'umd'
|
101 | },
|
102 | plugins: [
|
103 | vue(),
|
104 | ...plugins
|
105 | ]
|
106 | })
|
107 |
|
108 | out = 'dist/bootstrap-table-vue.esm.js'
|
109 | if (process.env.NODE_ENV === 'production') {
|
110 | out = out.replace(/.js$/, '.min.js')
|
111 | }
|
112 | config.push({
|
113 | input: 'src/vue/BootstrapTable.vue',
|
114 | output: {
|
115 | name: 'BootstrapTable',
|
116 | file: out,
|
117 | format: 'esm'
|
118 | },
|
119 | plugins: [
|
120 | vue(),
|
121 | ...plugins
|
122 | ]
|
123 | })
|
124 |
|
125 | export default config
|