Blame view

build/vite/optimizer.ts 541 Bytes
vben authored
1
// TODO
2
import type { GetManualChunk } from 'rollup';
3
4
5

//
const vendorLibs: { match: string[]; output: string }[] = [
vben authored
6
7
8
9
  // {
  //   match: ['xlsx'],
  //   output: 'xlsx',
  // },
10
11
12
];

// @ts-ignore
13
export const configManualChunk: GetManualChunk = (id: string) => {
14
15
16
17
18
19
20
21
  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;
  }
};