mirror of
https://github.com/vbenjs/vue-vben-admin.git
synced 2025-08-27 14:13:40 +08:00
test(code-split): code split optimization
This commit is contained in:
20
build/vite/optimizer.ts
Normal file
20
build/vite/optimizer.ts
Normal file
@@ -0,0 +1,20 @@
|
||||
import type { GetManualChunk, GetManualChunkApi } from 'rollup';
|
||||
|
||||
//
|
||||
const vendorLibs: { match: string[]; output: string }[] = [
|
||||
{
|
||||
match: ['xlsx'],
|
||||
output: 'xlsx',
|
||||
},
|
||||
];
|
||||
|
||||
// @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;
|
||||
}
|
||||
};
|
Reference in New Issue
Block a user