forked from kinglisky/egrid
-
Notifications
You must be signed in to change notification settings - Fork 0
/
rollup.config.js
62 lines (58 loc) · 1.59 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
const rollup = require('rollup')
const vue = require('rollup-plugin-vue2')
const resolve = require('rollup-plugin-node-resolve')
const babel = require('rollup-plugin-babel')
const uglify = require('rollup-plugin-uglify')
const ug = require('uglify-es')
const babelHelpers = require('babel-helpers')
const externalHelpersWhitelist = babelHelpers.list.filter(helperName => {
return helperName !== 'asyncGenerator'
})
const plugins = [
vue(),
resolve({
extensions: ['.js', '.vue']
}),
babel({
exclude: 'node_modules/**',
plugins: ['external-helpers'],
externalHelpersWhitelist
})
]
const config = {
name: 'Egrid',
entry: './src/index.js',
dist: 'lib/index'
}
const pkgs = [
{ format: 'cjs', suffix: '.com.js' },
{ format: 'cjs', suffix: '.com.min.js', min: true },
{ format: 'es', suffix: '.esm.js' },
{ format: 'es', suffix: '.esm.min.js', min: true },
{ format: 'umd', suffix: '.umd.js' },
{ format: 'umd', suffix: '.umd.min.js', min: true }
]
pkgs.forEach(runRollup)
function runRollup (it) {
rollup.rollup({
input: config.entry,
external: ['vue', 'element-ui/lib/table', 'element-ui/lib/table-column'],
plugins: it.min ? plugins.concat(uglify({}, ug.minify)) : plugins
})
.then(bundle => {
bundle.write({
format: it.format,
name: config.name,
globals: {
'vue': 'Vue',
'element-ui/lib/table': 'ELEMENT.Table',
'element-ui/lib/table-column': 'ELEMENT.TableColumn'
},
file: config.dist + it.suffix
})
})
.catch(e => {
console.log(`${it.format} - 打包出错:`, e)
process.exit(1)
})
}