-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathindex.js
47 lines (47 loc) · 1.44 KB
/
index.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
const defaultShakeApiList = [
'getWeRunData',
'chooseLocation',
'chooseInvoiceTitle',
'chooseInvoice',
'chooseImage',
'chooseMedia',
'chooseLicensePlate',
'openBluetoothAdapter',
'createBLEPeripheralServer',
'addPhoneContact',
'addPhoneRepeatCalendar',
'addPhoneCalender',
'saveFileToDisk',
'startLocationUpdateBackground',
'startLocationUpdate',
]
const WxShake = ({apiList}) => {
return {
configWebpack({config}) {
config.module
.rule('wx-shake')
.test(/index.js$/)
.use('string-replace-loader')
.loader('string-replace-loader')
.options({
multiple: apiList !== undefined ? apiList : defaultShakeApiList
.map((search, index) => {
const replace = `REPLACEMENT${index}`; // or use random string
return [
{
search,
replace
},
{
search: `wx.${search}`,
replace
}
];
})
.flat()
})
.end();
}
}
};
module.exports = WxShake;