提交 | 用户 | age
|
4cca00
|
1 |
import type { GetManualChunk, GetManualChunkApi } from 'rollup'; |
V |
2 |
|
|
3 |
// |
|
4 |
const vendorLibs: { match: string[]; output: string }[] = [ |
3509eb
|
5 |
// { |
V |
6 |
// match: ['xlsx'], |
|
7 |
// output: 'xlsx', |
|
8 |
// }, |
4cca00
|
9 |
]; |
V |
10 |
|
|
11 |
// @ts-ignore |
|
12 |
export const configManualChunk: GetManualChunk = (id: string, api: GetManualChunkApi) => { |
|
13 |
if (/[\\/]node_modules[\\/]/.test(id)) { |
|
14 |
const matchItem = vendorLibs.find((item) => { |
|
15 |
const reg = new RegExp(`[\\/]node_modules[\\/]_?(${item.match.join('|')})(.*)`, 'ig'); |
|
16 |
return reg.test(id); |
|
17 |
}); |
|
18 |
return matchItem ? matchItem.output : null; |
|
19 |
} |
|
20 |
}; |