-
Notifications
You must be signed in to change notification settings - Fork 296
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Idea: double-save to refresh browser #118
Comments
Interesting idea, it's possibly doable - depending on what the granularity of the file change event is after a save. At the moment I just let webpack watch the filesystem, so we would need to reach into webpack and grab the watchpack instance somehow - then compare timestamps of change events. Another similar option might be to have the middleware expose an HTTP endpoint which sends a force-reload message, and then have editor plugins ping that endpoint on a custom keybinding. |
@glenjamin Makes sense to me. I've finagled with Webpack a bit, so if I can work it out would you be open to a PR? (If it doesn't fit within this project, it can likely be a plugin instead). |
I'm happy to take a PR, possibly behind an option that's off by default initially. |
@glenjamin I <3 you. I'll see what I can do :) |
@matthiasak Pinging you since this came from our discussion! |
I don't have a ton of experience with the lower internals of webpack or webpack-hot-middleware, but I imagine you'll need to keep track of file hashes for the server-side code separately from the client-side. In https://github.com/matthiasak/universal-js-boilerplate-v3 I have two configs generated by my webpack.config.js. I use webpack-hot-middleware (WHM) to manage the client-side - and the app.use(require("webpack-hot-middleware")(compiler, {
serverEntry: ['/path/to/server-entry-file.js']
})) But this might have some extra overhead in-terms of watching the server files from both the WHM and let serverBundler = webpack(serverConfig)
app.use(require("webpack-hot-middleware")(compiler, {serverBundler})) |
WHM can't really do anything useful with a server bundle. There would be 2 parts to an implementation of the feature suggested here:
If you also wanted to force a refresh after server-side changes then that would hopefully only need (1) to be hooked up to the server bundle, and an appropriate method called on the middleware instance. |
I figured it made the most sense to solve it in two steps:
As noted, they'll require 2 different solutions. |
tldr; Save a file once, everything's normal. Save a file twice (like a double-tap), browser refreshes.
Scenario
reload
event and I correctly see 0 left in stock.I'm asking here because
webpack-hot-middleware
is what's triggering reload events in the browser and seems like a likely place to be able to trigger the event.Cool DX, but doable? I'd be happy to help if you can help me figure out where to even do this.
The text was updated successfully, but these errors were encountered: