UNPKG

2.41 kBJavaScriptView Raw
1import glob from 'glob'
2import { babel } from '@rollup/plugin-babel'
3import { nodeResolve } from '@rollup/plugin-node-resolve'
4import commonjs from '@rollup/plugin-commonjs'
5import { terser } from 'rollup-plugin-terser'
6import inject from '@rollup/plugin-inject'
7import copy from 'rollup-plugin-copy'
8import multiEntry from '@rollup/plugin-multi-entry'
9import vue from 'rollup-plugin-vue'
10
11const files = glob.sync('src/**/*.js', {
12 ignore: [
13 'src/constants/**',
14 'src/utils/**',
15 'src/virtual-scroll/**',
16 'src/vue/**'
17 ]
18})
19const external = ['jquery']
20const globals = {
21 jquery: 'jQuery'
22}
23const config = []
24const 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
43if (process.env.NODE_ENV === 'production') {
44 plugins.push(terser({
45 output: {
46 comments () {
47 return false
48 }
49 }
50 }))
51}
52
53for (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
72let out = 'dist/bootstrap-table-locale-all.js'
73
74if (process.env.NODE_ENV === 'production') {
75 out = out.replace(/.js$/, '.min.js')
76}
77config.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
92out = 'dist/bootstrap-table-vue.js'
93if (process.env.NODE_ENV === 'production') {
94 out = out.replace(/.js$/, '.min.js')
95}
96config.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
109out = 'dist/bootstrap-table-vue.esm.js'
110if (process.env.NODE_ENV === 'production') {
111 out = out.replace(/.js$/, '.min.js')
112}
113config.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
126export default config