UNPKG

2.19 kBJavaScriptView Raw
1import glob from 'glob'
2import babel from 'rollup-plugin-babel'
3import resolve from 'rollup-plugin-node-resolve'
4import commonjs from 'rollup-plugin-commonjs'
5import { terser } from 'rollup-plugin-terser'
6import inject from 'rollup-plugin-inject'
7import multiEntry from 'rollup-plugin-multi-entry'
8import vue from 'rollup-plugin-vue'
9
10const files = glob.sync('src/**/*.js', {
11 ignore: [
12 'src/constants/**',
13 'src/utils/**',
14 'src/virtual-scroll/**',
15 'src/vue/**'
16 ]
17})
18const external = ['jquery']
19const globals = {
20 jquery: 'jQuery'
21}
22const config = []
23const 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
36if (process.env.NODE_ENV === 'production') {
37 plugins.push(terser({
38 output: {
39 comments () {
40 return false
41 }
42 }
43 }))
44}
45
46for (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
64let out = 'dist/bootstrap-table-locale-all.js'
65if (process.env.NODE_ENV === 'production') {
66 out = out.replace(/.js$/, '.min.js')
67}
68config.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
83out = 'dist/bootstrap-table-vue.js'
84if (process.env.NODE_ENV === 'production') {
85 out = out.replace(/.js$/, '.min.js')
86}
87config.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
100out = 'dist/bootstrap-table-vue.esm.js'
101if (process.env.NODE_ENV === 'production') {
102 out = out.replace(/.js$/, '.min.js')
103}
104config.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
117export default config