-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathconfigs.js
73 lines (61 loc) · 1.42 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
const path = require('path')
const nodeResolve = require('rollup-plugin-node-resolve')
const commonjs = require('rollup-plugin-commonjs')
const resolve = _path => path.resolve(__dirname, '../', _path)
const configs = {
umdDev: {
input: resolve('lib/index.cjs.js'),
file: resolve('dist/vuex-orm-decorator.js'),
format: 'umd',
env: 'development'
},
umdProd: {
input: resolve('lib/index.cjs.js'),
file: resolve('dist/vuex-orm-decorator.min.js'),
format: 'umd',
env: 'production'
},
commonjs: {
input: resolve('lib/index.cjs.js'),
file: resolve('dist/vuex-orm-decorator.common.js'),
format: 'cjs'
},
esm: {
input: resolve('lib/index.js'),
file: resolve('dist/vuex-orm-decorator.esm.js'),
format: 'es'
}
}
function genConfig (opts) {
return {
input: {
input: opts.input,
plugins: [
nodeResolve(),
commonjs()
],
onwarn (warning) {
if (warning.code === 'THIS_IS_UNDEFINED') {
return
}
if (warning.code === 'CIRCULAR_DEPENDENCY') {
return
}
console.error(warning.message)
}
},
output: {
name: 'VuexORM',
file: opts.file,
format: opts.format
}
}
}
function mapValues (obj, fn) {
const res = {}
Object.keys(obj).forEach(key => {
res[key] = fn(obj[key], key)
})
return res
}
module.exports = mapValues(configs, genConfig)