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 | 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 |
|
70 | let out = 'dist/bootstrap-table-locale-all.js'
|
71 | if (process.env.NODE_ENV === 'production') {
|
72 | out = out.replace(/.js$/, '.min.js')
|
73 | }
|
74 | config.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 |
|
89 | out = 'dist/bootstrap-table-vue.js'
|
90 | if (process.env.NODE_ENV === 'production') {
|
91 | out = out.replace(/.js$/, '.min.js')
|
92 | }
|
93 | config.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 |
|
106 | out = 'dist/bootstrap-table-vue.esm.js'
|
107 | if (process.env.NODE_ENV === 'production') {
|
108 | out = out.replace(/.js$/, '.min.js')
|
109 | }
|
110 | config.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 |
|
123 | export default config
|