-
Notifications
You must be signed in to change notification settings - Fork 2.7k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
refactor(preset-umi): make 3rd-party chunk name clean (#11716)
- Loading branch information
1 parent
170863c
commit 8e4db78
Showing
1 changed file
with
7 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -315,9 +315,15 @@ export function componentToChunkName( | |
), | ||
'', | ||
) | ||
// 丢弃 .pnpm 下的多层 node_modules 避免 chunkName 过长 | ||
// ex. node_modules/.pnpm/[email protected]_xxxx/node_modules/dumi/dist/client/pages/404 | ||
.replace(/.+(node_modules(\/|\\))/, '$1') | ||
// 丢弃 tnpm 目录下的软链结构避免 chunkName 过长 | ||
// ex. node_modules/_@umijs_utils@4.0.83@@umijs/utils/dist/index.js | ||
.replace(/(\/|\\)_@?([^@]+@){2}/, '$1') | ||
.replace(/^.(\/|\\)/, '') | ||
.replace(/(\/|\\)/g, '__') | ||
// 转换 tnpm node_modules 目录中的 @ 符号,它在 URL 上会被转义,可能导致 CDN 托管失败 | ||
// 转换 node_modules 目录中的 @ 符号,它在 URL 上会被转义,可能导致 CDN 托管失败 | ||
.replace(/@/g, '_') | ||
.replace(/\.jsx?$/, '') | ||
.replace(/\.tsx?$/, '') | ||
|