zhou zhou
50 分钟以前 a49845f424ae5b1e43e391837a55c43ce07ea62d
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
const CHUNK_GROUPS = [
  {
    name: 'vendor-echarts',
    packages: ['echarts/']
  },
  {
    name: 'vendor-editor',
    packages: ['@wangeditor/', 'highlight.js/']
  },
  {
    name: 'vendor-xlsx',
    packages: ['xlsx/']
  },
  {
    name: 'vendor-media',
    packages: ['xgplayer/']
  },
  {
    name: 'vendor-element-plus',
    packages: ['element-plus/', '@element-plus/']
  },
  {
    name: 'vendor-vue',
    packages: ['vue-router/', 'pinia/', '@vueuse/']
  },
  {
    name: 'vendor-utils',
    packages: ['@iconify/', 'file-saver/', 'axios/']
  }
]
 
function createManualChunks(id) {
  if (!id || !id.includes('/node_modules/')) {
    return void 0
  }
 
  const normalizedId = id.replace(/\\/g, '/')
  const packagePath = normalizedId.split('/node_modules/').pop() || ''
 
  for (const group of CHUNK_GROUPS) {
    if (group.packages.some((pkg) => packagePath.startsWith(pkg))) {
      return group.name
    }
  }
 
  return void 0
}
 
export { createManualChunks }