Skip to content

Commit b7c548b

Browse files
committed
fix: support legacy npm potocol in CDN link extraction
1 parent 2f07e6a commit b7c548b

1 file changed

Lines changed: 12 additions & 0 deletions

File tree

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

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,18 @@ const { readJsonSync } = fs
1515
export function extraBundleCdnLink(filename, originCdnPrefix) {
1616
const result = new Set()
1717
const bundle = readJsonSync(filename)
18+
// 兼容旧版的 npm 协议
19+
bundle.data?.materials?.components?.forEach((component) => {
20+
if (component.npm) {
21+
const possibleUrl = [component.npm.script, component.npm.css]
22+
possibleUrl.forEach((url) => {
23+
if (url?.startsWith(originCdnPrefix) && !result.has(url)) {
24+
result.add(url)
25+
}
26+
})
27+
}
28+
})
29+
1830
bundle.data?.materials?.packages?.forEach((packageItem) => {
1931
if (packageItem) {
2032
const possibleUrl = [packageItem.script, packageItem.css]

0 commit comments

Comments
 (0)