-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathrollup.config.mjs
96 lines (79 loc) · 1.89 KB
/
rollup.config.mjs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
import resolve from '@rollup/plugin-node-resolve';
import commonjs from '@rollup/plugin-commonjs';
import terser from '@rollup/plugin-terser';
import json from '@rollup/plugin-json';
import multiEntry from '@rollup/plugin-multi-entry'
import babel from '@rollup/plugin-babel';
import stripBanner from 'rollup-plugin-strip-banner';
import {globSync} from 'glob'
import {getBanner} from "./build/banner.mjs"
const files = globSync('src/js/langs/*.js')
const plugins = [
resolve(),
commonjs(),
json(),
stripBanner({
include: '**/*.js',
exclude: 'node_modules/**'
}),
babel({
babelHelpers: 'bundled'
})
]
if (process.env.NODE_ENV === 'production') {
plugins.push(terser({
output: {
comments() {
return false
}
}
}))
}
let file = 'dist/js/quicktab.js'
if (process.env.NODE_ENV === 'production') {
file = file.replace(/\.js$/, '.min.js')
}
const config = [{
input: 'src/js/quicktab.js',
output: {
banner: getBanner(),
format: 'umd',
name: 'Quicktab',
sourcemap: true,//方便调试
file
},
plugins
}]
// 所有的js文件合并成一个js文件
file = 'dist/js/langs/all.js'
if (process.env.NODE_ENV === 'production') {
file = file.replace(/\.js$/, '.min.js')
}
config.push({
input: 'src/js/langs/**/*.js',
output: {
name: 'Quicktab',
file,
format: 'umd'
},
plugins: [
multiEntry(),
...plugins
]
})
for (const input of files) {
let file = `dist/${input.replace(/\\/g, '/').replace('src/', '')}`;
if (process.env.NODE_ENV === 'production') {
file = file.replace(/\.js$/, '.min.js')
}
config.push({
input,
output: {
name: 'Quicktab',
file,
format: 'umd',
},
plugins
})
}
export default config;