-
Notifications
You must be signed in to change notification settings - Fork 4
/
rollup.config.js
111 lines (106 loc) · 2.1 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
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
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
const commonjs = require('rollup-plugin-commonjs')
const babel = require('rollup-plugin-babel')
const pkg = require('./package.json')
const now = (new Date()).toLocaleString() || ''
const banner = `
/**
* ${pkg.name}
* -------------
* VERSION: v${pkg.version}
* UPDATE: ${now.split(' ')[0]}
*
* by tomieric <[email protected]>
* (c) www.kuaizi.ai
*/
`
const config = {
'index': {
commonjs: {
output: {
file: 'dist/index.js',
format: 'cjs',
banner
},
plugins: [
commonjs({
include: 'node_modules/**',
}),
babel({
babelrc: false,
presets: [['es2015', { modules: false }]],
})
]
},
esm: {
output: {
file: 'dist/index.esm.js',
format: 'es',
banner
},
plugins: []
}
},
'table': {
commonjs: {
output: {
file: 'dist/kz-table.js',
format: 'cjs',
banner
},
plugins: [
commonjs({
include: 'node_modules/**',
}),
babel({
babelrc: false,
presets: [['es2015', { modules: false }]],
})
]
},
esm: {
output: {
file: 'dist/kz-table.esm.js',
format: 'es',
banner
},
plugins: []
}
},
'table-column': {
commonjs: {
output: {
file: 'dist/kz-table-column.js',
format: 'cjs',
banner
},
plugins: [
babel({
babelrc: false,
presets: [['es2015', { modules: false }]],
}),
commonjs()
]
},
esm: {
output: {
file: 'dist/kz-table-column.esm.js',
format: 'es',
banner
},
plugins: []
}
}
}
export default ['index', 'table', 'table-column'].reduce((prev, file) => {
const c = Object.keys(config[file]).map(mode => ({
input: `./src/${file}.js`,
output: Object.assign(config[file][mode].output, {
globals: {
'element-ui': 'element-ui'
}
}),
external: [ 'element-ui' ],
plugins: config[file][mode].plugins
}))
return prev.concat(c)
}, [])