-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathrollup.config.js
44 lines (41 loc) · 1.15 KB
/
rollup.config.js
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
import commonjs from 'rollup-plugin-commonjs'
import json from 'rollup-plugin-json'
import { terser } from 'rollup-plugin-terser'
const activeConfigs = [{
input: 'index.js',
output: {
file: 'dist/mdkeywords.umd.js',
name: 'mdkeywords',
exports: 'named',
format: 'umd'
},
plugins: [commonjs(), json()]
}, {
input: 'index.js',
output: {
file: 'dist/mdkeywords.es.js',
name: 'mdkeywords',
exports: 'named',
format: 'esm'
},
plugins: [commonjs(), json()]
}]
const minifiedConfigs = activeConfigs.reduce(
(minifiedConfigs, activeConfig) => {
if (activeConfig.output.file.indexOf('dist') !== -1) {
return minifiedConfigs.concat(
Object.assign({}, activeConfig, {
plugins: [terser(), ...activeConfig.plugins],
output: {
file: activeConfig.output.file.replace('js', 'min.js'),
format: activeConfig.output.format,
name: activeConfig.output.name,
exports: activeConfig.output.exports
}
})
)
}
return minifiedConfigs
}, [])
// export default activeConfigs.concat(minifiedConfigs)
export default minifiedConfigs