fix(replace-assets): correct asset paths and enhance JS preload tag handling
This commit is contained in:
parent
5bfbbe163b
commit
f2d7606aba
1 changed files with 10 additions and 2 deletions
|
|
@ -46,8 +46,8 @@ function replaceAssets() {
|
||||||
};
|
};
|
||||||
const cssHash = safeHash(cssMinPath);
|
const cssHash = safeHash(cssMinPath);
|
||||||
const jsHash = safeHash(jsMinPath);
|
const jsHash = safeHash(jsMinPath);
|
||||||
const cssTarget = cssHash ? `href="./css/styles-min.css?v=${cssHash}"` : 'href="./css/styles-min.css"';
|
const cssTarget = cssHash ? `href="/css/styles-min.css?v=${cssHash}"` : 'href="/css/styles-min.css"';
|
||||||
const jsTarget = jsHash ? `src="js/app-min.js?v=${jsHash}"` : 'src="js/app-min.js"';
|
const jsTarget = jsHash ? `src="/js/app-min.js?v=${jsHash}"` : 'src="/js/app-min.js"';
|
||||||
|
|
||||||
// Replace CSS links in head - more flexible patterns
|
// Replace CSS links in head - more flexible patterns
|
||||||
const cssPatterns = [
|
const cssPatterns = [
|
||||||
|
|
@ -72,6 +72,14 @@ function replaceAssets() {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Update JS preload tags to include version hash
|
||||||
|
if (jsHash) {
|
||||||
|
const preloadMinJsPattern = /href=["']\/?js\/app-min\.js["']/g;
|
||||||
|
if (preloadMinJsPattern.test(updatedHeadContent)) {
|
||||||
|
updatedHeadContent = updatedHeadContent.replace(preloadMinJsPattern, `href="/js/app-min.js?v=${jsHash}"`);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// Replace JS script src in head - more flexible patterns
|
// Replace JS script src in head - more flexible patterns
|
||||||
const jsPatterns = [
|
const jsPatterns = [
|
||||||
/src=["']\.\/js\/app\.js["']/g,
|
/src=["']\.\/js\/app\.js["']/g,
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue