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