forked from dcloudio/uni-app
-
Notifications
You must be signed in to change notification settings - Fork 0
/
rollup.config.mp.js
85 lines (80 loc) · 2.04 KB
/
rollup.config.mp.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
const path = require('path')
const json = require('@rollup/plugin-json')
const alias = require('@rollup/plugin-alias')
const replace = require('@rollup/plugin-replace')
const PLATFORMS = {
'mp-weixin': {
prefix: 'wx',
title: '微信小程序'
},
'mp-qq': {
prefix: 'wx',
title: 'QQ小程序'
},
'mp-alipay': {
prefix: 'my',
title: '支付宝小程序'
},
'mp-baidu': {
prefix: 'swan',
title: '百度小程序'
},
'mp-toutiao': {
prefix: 'tt',
title: '头条小程序'
},
'mp-kuaishou': {
prefix: 'ks',
title: '快手小程序'
},
'quickapp-webview': {
prefix: 'qa',
title: '快应用(Webview)版'
},
'app-plus': {
prefix: 'wx',
title: 'app-plus'
}
}
const platform = PLATFORMS[process.env.UNI_PLATFORM]
let input = 'src/core/runtime/index.js'
const output = {
file: `packages/uni-${process.env.UNI_PLATFORM}/dist/index.js`,
format: 'es'
}
if (process.env.UNI_MP) {
input = 'src/core/runtime/mp/index.js'
output.file = `packages/uni-${process.env.UNI_PLATFORM}/dist/mp.js`
}
module.exports = {
input,
output,
plugins: [
alias({
entries: [{
find: 'uni-shared/query',
replacement: path.resolve(__dirname, '../src/shared/query.js')
}, {
find: 'uni-shared',
replacement: path.resolve(__dirname, '../src/shared/util.js')
}, {
find: 'uni-platform',
replacement: path.resolve(__dirname, '../src/platforms/' + process.env.UNI_PLATFORM)
}, {
find: 'uni-wrapper',
replacement: path.resolve(__dirname, '../src/core/runtime/wrapper')
}, {
find: 'uni-helpers',
replacement: path.resolve(__dirname, '../src/core/helpers')
}]
}),
json(),
replace({
__GLOBAL__: platform.prefix,
__PLATFORM_TITLE__: platform.title,
__PLATFORM_PREFIX__: JSON.stringify(platform.prefix),
__PLATFORM__: JSON.stringify(process.env.UNI_PLATFORM)
})
],
external: ['vue']
}