Skip to content
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

Pause server and wait for Webpack to compile #43

Closed
drewhamlett opened this issue Dec 24, 2016 · 6 comments
Closed

Pause server and wait for Webpack to compile #43

drewhamlett opened this issue Dec 24, 2016 · 6 comments

Comments

@drewhamlett
Copy link

drewhamlett commented Dec 24, 2016

This is an issue we've ran into with our own Webpack solution as well as something this plugin will face. When you save a asset and refresh the page you're not exactly sure if the asset has finished compiling. Most of the time the bundle compilation is super fast if extracting out vendor dependencies, but it can an issue. This is something the Webpack dev server kind of does for you but in this case we're not running through it. We've landed on just using the notification plugin to show OS notification when bundle has compiled successfully(or has failed). While this works it's not ideal. Another solution is Live Reload or Browser sync, but I've never been a huge fan of these outside of CSS reloading.

It would be nice to pause the server until asset has finished compiling completely. This is something the Django Webpack project does. https://github.com/owais/django-webpack-loader/blob/6c297a038a60f21356d4dc6bbfedd8ad49a34731/webpack_loader/loader.py

It could even be taken a step farther and show errors in the browser much like sprockets does. The stats.json holds most of this information.

Is this something anyone is interested in?

@dhh
Copy link
Member

dhh commented Dec 26, 2016 via email

@dhh dhh closed this as completed Dec 26, 2016
@cgarvis
Copy link
Contributor

cgarvis commented Jan 11, 2017

I have a project were the webpack build takes 27396ms on my computer. It would be nice to have rails pause and wait for it.

@dhh
Copy link
Member

dhh commented Jan 12, 2017

We now have a PR that's nearing completion to use the webpack-dev-server. I think that's the way to go for this.

@sspread
Copy link
Contributor

sspread commented Nov 12, 2017

+1 this is what's missing from my workflow. I don't want to watch the watcher feedback or guess when webpack is done compiling and ready for me to manually reload the browser. webpack-dev-server allows for auto browser reload, but I do not want this behavior as I often go between text editor and web dev tools quickly and auto browser reload is too jarring. And finally, a compile on every request (not using watcher or webpack-dev-server) takes too long.

Ideally webpack-dev-server watches for changes and compiles as it currently does, without auto browser reload. A request to the server is then blocked while it waits for an in-process webpack compilation to complete. AFAIK there isn't any way to accomplish this through configuration, is there? If not, a polling approach like in the Django Webpack project mentioned above could work (https://github.com/ezhome/django-webpack-loader/blob/6c297a038a60f21356d4dc6bbfedd8ad49a34731/webpack_loader/loader.py#L66-L70)

@gauravtiwari
Copy link
Member

@sspread You mean, you want to use watcher the same way as dev server i.e. if using watcher it should auto reload like dev server does?

There are two solutions:

  1. You can turn off auto reload for dev server (as needed) then manually reload but I guess the behaviour will be more or less same as watcher.
  2. Use hot reload API to don't reload at all but hot update the UI

@sspread
Copy link
Contributor

sspread commented Nov 12, 2017

@gauravtiwari I do not want auto reload of browser. I want full control (manual reload browser). However, I also want to utilize the speed of watcher and dev-server because it only recompiles what it needs after a change in css/js. The problem is, if I disable auto-reload and manually reload the browser while webpack is still compiling, I will get the stale assets. My ideal behavior in this case is for the request to hang until the compile is complete.

In effect, I want the same old behavior as sprockets, but browser reloads will be faster because of efficient 'piecewise' recompiling by webpack.

note - hot reload api may be a step in the right direction but now its too much work to port my legacy code to make that work, especially with css.

tricknotes pushed a commit to tricknotes/webpacker that referenced this issue Feb 7, 2022
* Test and lint against node 16 too
* Upgrading Rubocop and Rspec workflows with latest version of Ruby and Rails
* Using string for ruby versions
* Removing TargetRubyVersion in rubocop
* Updating node-version to latest LTS
* Removing Ruby 3.1 in workflows
* remove ruby 3.0 from ruby specs workflow
* add ruby 2.6 into ruby specs workflow
* specify ruby 2.6 to use Gemfile rails 5.2.x to 6.1x
* add ruby 3.0 into ruby specs workflow
* support ruby 2.6 in workflow
* exclude ruby 3.0 from using rails 5.2

Co-authored-by: Guillaume Briday <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants