Skip to content

Commit 83e92c8

Browse files
committed
fix: replace bundle cdnLink support old protocol
1 parent e9b75c4 commit 83e92c8

1 file changed

Lines changed: 13 additions & 0 deletions

File tree

packages/build/vite-config/src/localCdnFile/copyBundleDeps.js

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,19 @@ export function extraBundleCdnLink(filename, originCdnPrefix) {
4242
}
4343

4444
export function replaceBundleCdnLink(bundle, fileMap) {
45+
// 兼容旧版的 npm 协议
46+
bundle.data?.materials?.components?.forEach((component) => {
47+
if (component.npm) {
48+
const possibleUrl = ['script', 'css']
49+
possibleUrl.forEach((key) => {
50+
const matchRule = fileMap.find((rule) => component.npm[key] === rule.originUrl)
51+
if (matchRule) {
52+
component.npm[key] = matchRule.newUrl
53+
}
54+
})
55+
}
56+
})
57+
4558
bundle.data?.materials?.packages?.forEach((packageItem) => {
4659
if (packageItem) {
4760
const possibleUrl = ['script', 'css']

0 commit comments

Comments
 (0)