vben
2021-02-09 07c18d602ec47215c0390096a3fa66b40004d041
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
// TODO
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) => {
  console.log(api);
  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;
  }
};