DEV Community

Discussion on: Deploy Astro site to sub-path

Collapse
 
wbern profile image
William Bernting • Edited

To cover for relative ./assets paths, I used this instead. You can remove all the String(...).replace in the above code and replace with this (6 to 3 lines by account for single and double-quotes in the same regex).

content = String(content).replace(/src=["'][.]{0,1}\//g, `src="${PRODUCTION_URL}`);
          content = String(content).replace(/href=["'][.]{0,1}\//g, `href="${PRODUCTION_URL}`);
          content = String(content).replace(/url\(["'][.]{0,1}\//g, `url("${PRODUCTION_URL}`);
Enter fullscreen mode Exit fullscreen mode
Collapse
 
jonas_duri profile image
Jonas Duri

Great, thanks!