-
-
Notifications
You must be signed in to change notification settings - Fork 5k
/
Copy pathconfigs.js
83 lines (77 loc) · 1.7 KB
/
configs.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
const path = require('path')
const buble = require('rollup-plugin-buble')
const flow = require('rollup-plugin-flow-no-whitespace')
const cjs = require('rollup-plugin-commonjs')
const node = require('rollup-plugin-node-resolve')
const replace = require('rollup-plugin-replace')
const version = process.env.VERSION || require('../package.json').version
const banner =
`/*!
* vue-router v${version}
* (c) ${new Date().getFullYear()} Evan You
* @license MIT
*/`
const resolve = _path => path.resolve(__dirname, '../', _path)
module.exports = [
// browser dev
{
file: resolve('dist/vue-router.js'),
format: 'umd',
env: 'development'
},
{
file: resolve('dist/vue-router.min.js'),
format: 'umd',
env: 'production'
},
{
file: resolve('dist/vue-router.common.js'),
format: 'cjs'
},
{
file: resolve('dist/vue-router.esm.js'),
format: 'es'
},
{
file: resolve('dist/vue-router.esm.browser.js'),
format: 'es',
env: 'development',
transpile: false
},
{
file: resolve('dist/vue-router.esm.browser.min.js'),
format: 'es',
env: 'production',
transpile: false
}
].map(genConfig)
function genConfig (opts) {
const config = {
input: {
input: resolve('src/index.js'),
plugins: [
flow(),
node(),
cjs(),
replace({
__VERSION__: version
})
]
},
output: {
file: opts.file,
format: opts.format,
banner,
name: 'VueRouter'
}
}
if (opts.env) {
config.input.plugins.unshift(replace({
'process.env.NODE_ENV': JSON.stringify(opts.env)
}))
}
if (opts.transpile !== false) {
config.input.plugins.push(buble())
}
return config
}