fix(replace-assets): correct asset paths and enhance JS preload tag handling

This commit is contained in:
fynks 2025-10-24 10:21:08 +05:00
parent 5bfbbe163b
commit f2d7606aba

View file

@ -46,8 +46,8 @@ function replaceAssets() {
};
const cssHash = safeHash(cssMinPath);
const jsHash = safeHash(jsMinPath);
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 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"';
// Replace CSS links in head - more flexible patterns
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
const jsPatterns = [
/src=["']\.\/js\/app\.js["']/g,