2020-12-04 23:35:58 +08:00
|
|
|
import type { GetManualChunk, GetManualChunkApi } from 'rollup';
|
|
|
|
|
|
|
|
//
|
|
|
|
const vendorLibs: { match: string[]; output: string }[] = [
|
2021-01-11 00:16:44 +08:00
|
|
|
// {
|
|
|
|
// match: ['xlsx'],
|
|
|
|
// output: 'xlsx',
|
|
|
|
// },
|
2020-12-04 23:35:58 +08:00
|
|
|
];
|
|
|
|
|
|
|
|
// @ts-ignore
|
|
|
|
export const configManualChunk: GetManualChunk = (id: string, api: GetManualChunkApi) => {
|
|
|
|
if (/[\\/]node_modules[\\/]/.test(id)) {
|
|
|
|
const matchItem = vendorLibs.find((item) => {
|
|
|
|
const reg = new RegExp(`[\\/]node_modules[\\/]_?(${item.match.join('|')})(.*)`, 'ig');
|
|
|
|
return reg.test(id);
|
|
|
|
});
|
|
|
|
return matchItem ? matchItem.output : null;
|
|
|
|
}
|
|
|
|
};
|