Skip to content

Commit

Permalink
Merge pull request #76 from bcole808/fix-css-live-reload
Browse files Browse the repository at this point in the history
Fix CSS live reload behavior when some stylesheets have no URL
  • Loading branch information
zachleat committed Apr 19, 2024
2 parents 433d8ff + 5733738 commit bc1cdd1
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions client/reload-client.js
Original file line number Diff line number Diff line change
Expand Up @@ -176,9 +176,11 @@ class EleventyReload {
async onreload({ subtype, files, build }) {
if (subtype === "css") {
for (let link of document.querySelectorAll(`link[rel="stylesheet"]`)) {
let url = new URL(link.href);
url.searchParams.set("_11ty", Date.now());
link.href = url.toString();
if (link.href) {
let url = new URL(link.href);
url.searchParams.set("_11ty", Date.now());
link.href = url.toString();
}
}
Util.log(`CSS updated without page reload.`);
} else {
Expand Down

0 comments on commit bc1cdd1

Please sign in to comment.