Replies: 3 comments 2 replies
-
Fantastic proposal. I actually took a stab at this but got more ambitious: hot reloading with ViteJS. And I actually used the second approach you suggested: #262 The meat of the PR is here: https://github.com/silviogutierrez/reactivated/pull/262/files#diff-0e1e2185c8fc5a4a141f702ae6c4317493a0c644ce0a06b3754f7fd7cf4e0817 Some of my projects have SPA sections where live reloading isn't of much help, it takes a few seconds to reload. So I wanted true hot reloading. Your approach is simpler and worth considering though. I do hate opening random ports because it's non-deterministic. Notice the renderer uses a UNIX socket instead of a port. Curious if we could get ESBuild to do the same thing. We'd also need to inject the ESBuild reloading code: Finally, I'm not entirely sure how good proxying of server-sent events works with Django. Thus, in my Vite POC, I piped directly to the Vite server for assets. So what stopped me? Vite and Linaria simply did not play well together. In fact, nothing plays well with Linaria. So much so that it's been removed from reactivated: #311 Now that that's gone, I may take a stab at Vite again. But you're welcome to give this a try, if it's drop-in easy, it may just be the best path forward. |
Beta Was this translation helpful? Give feedback.
-
That's a very good point—it'd probably be a chore to get that to work properly. Especially since the dev server restarts on code change, which would mean the WS connection would drop too. As soon as I get a chance I'll prototype option 2, but with the esbuild server instead of your Vite version. To be completely honest I'm not a huge fan of Vite—it seems vastly over-complicated and having the dev bundle be so different from prod makes me nervous. But, that's just me and not especially empirical, so feel free to disregard. 😀 |
Beta Was this translation helpful? Give feedback.
-
ESBuild proof of concept submitted: #322 |
Beta Was this translation helpful? Give feedback.
-
One of the things the front-end developers on my team miss when working on reactivated projects is live-reload. We had this previously when using webpack, and I see that esbuild has some support for it—not to webpack's level of doing HMR—but it at least supports trigger a browser refresh on change. I have an idea for how this could be enabled in reactivated.
Current state:
Proposed design:
/static/dist/*
and, instead of serving the files from disk, proxies the request to the ESBuild server./esbuild
to the ESBuild server.An alternative approach would be to simply have the browser request static files direct from the ESBuild. This would negate the need to have Django proxy requests, but would mean that the client would need to know to request it's assets from an alternate domain/port than the Django server is running on. Having Django proxy the requests means that the client can request the static files from the same URL regardless of whether the app is in production or not. And, obviously, this extra server process and proxy view would only exist in development—nothing would change in production mode.
Let me know what you think.
Beta Was this translation helpful? Give feedback.
All reactions