Adding lifecycle hooks for dev mode #3737
Replies: 3 comments 1 reply
-
Instead of updating remix.config you can do this in userland. I have my own // components/LiveReload.tsx
export default function LiveReload({ port = Number(8002) }: { port?: number }) {
//...
let ws = new WebSocket(socketPath)
ws.onmessage = message => {
let event = JSON.parse(message.data)
if (event.type === 'LOG') {
console.log(event.message)
}
if (event.type === 'RELOAD') {
console.log('💿 Reloading window ...')
fetch('/build/__purge__').finally(() => {
window.location.reload()
})
}
}
//...
// server.js
app.use('/build/__purge__', (req, res) => {
console.log('💿 Purging require cache')
purgeRequireCache()
return res.send('ok')
}) |
Beta Was this translation helpful? Give feedback.
-
I have been using this the previous two weeks and it is that the |
Beta Was this translation helpful? Give feedback.
-
I ended up patching this directly in
|
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
I want to RFC this POC adding the ability to execute callbacks at the end of Remix finishing its rebuild. The motivation for this is to improve DX. Currently the status quo is to
purgeRequireCache()
on every request regardless, if needed or not, which adds to overall processing time of request. Since purging the cache is only required after a rebuild, we can achieve this by adding the small amount of code.In remix.config.js:
In server.js: (using Express here)
POC Implementation: ZipBrandon@0bd0eed
Things to do:
Beta Was this translation helpful? Give feedback.
All reactions