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

Automatic browser refresh without HTML changes #43

Closed
glenjamin opened this issue Aug 31, 2015 · 8 comments
Closed

Automatic browser refresh without HTML changes #43

glenjamin opened this issue Aug 31, 2015 · 8 comments

Comments

@glenjamin
Copy link

on https://christianalfoni.github.io/react-webpack-cookbook/Automatic-browser-refresh.html

Instead of adding http://localhost:8080/webpack-dev-server.js to the HTML, you can add webpack-dev-server/client?http://localhost:8080 to the entry list.

This also makes it easier to disable HMR changes in production builds.

@bebraw
Copy link
Member

bebraw commented Sep 1, 2015

@glenjamin What if we changed the recommendation to webpack-dev-server inline? That way we wouldn't need an entry at all given it injects one automatically. As a bonus tweaking the ip and port becomes easier.

@glenjamin
Copy link
Author

That would work too, the downside being that it's not quite as clear what is going on if you want to tweak the config.

@bebraw
Copy link
Member

bebraw commented Sep 1, 2015

Ok, I'll change it to what you proposed and link to an alternative resource for inline based setup with a bit different ideas.

@bebraw bebraw closed this as completed in efb7b5b Sep 1, 2015
@idisblueflash
Copy link

I've got error by changing to config of @glenjamin:

What I did:

  • remove <script src="http://localhost:8080/webpack-dev-server.js"></script> in my index.html
  • and add entry: 'webpack-dev-server/client?http://localhost:8080', in webpack.config.js

I've got a blank page and error on console:
[HMR] Waiting for update signal from WDS...
TypeError: undefined is not an object (evaluating 'global.WebSocket')

I try to comment // 'webpack-dev-server/client?http://localhost:8080', first page is ok, but I didn't get Automatic browser refresh. Did I miss some thing?

@bebraw
Copy link
Member

bebraw commented Sep 2, 2015

Any idea @glenjamin? Do you have working configuration to compare against?

@glenjamin
Copy link
Author

I'll try and dig one out - I haven't used this for a while as I've moved to using my webpack-dev-middleware instead.

@glenjamin
Copy link
Author

Looks like the approach I describe is the same one react-hot-boilerplate currently uses.

https://github.com/gaearon/react-hot-boilerplate/blob/3883f8ac7181aa42eed2485e7c72ea7599d7792e/webpack.config.js

@MacgyverMartins
Copy link

I had the some error @idisblueflash and I fix it changing npm script from:
"dev": "webpack-dev-server --devtool eval --progress --colors --content-base build"
to:
"dev": "webpack-dev-server --devtool eval --progress --colors --hot --content-base build"

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

4 participants