Blame view

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

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

// @ts-ignore
export const configManualChunk: GetManualChunk = (id: string, api: GetManualChunkApi) => {
vben authored
14
  console.log(api);
15
16
17
18
19
20
21
22
  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;
  }
};