Skip to content

Commit

Permalink
Live-reload config css changes during dev
Browse files Browse the repository at this point in the history
  • Loading branch information
benmerckx committed Jan 25, 2024
1 parent 916a0bd commit 07786dd
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 1 deletion.
4 changes: 3 additions & 1 deletion apps/dev/src/PositionField.module.css
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
.field {
background: #eee;
border: 1px solid #eaeaef;
border-radius: 8px;
padding: 20px;
}
8 changes: 8 additions & 0 deletions src/dashboard/dev/DevDashboard.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,14 @@ export function DevDashboard({loadConfig}: DevDashboardOptions) {
})
}, [config])
function getConfig() {
// Reload css
const link = document.querySelector(
'link[href^="/entry.css"]'
) as HTMLLinkElement
const copy = link.cloneNode() as HTMLLinkElement
copy.href = '/entry.css?' + Math.random()
copy.onload = () => link.remove()
link.after(copy)
return loadConfig().then(setConfig)
}
useEffect(() => {
Expand Down

0 comments on commit 07786dd

Please sign in to comment.