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

Force page reload in Development when external files have changed #1508

Closed
nuthinking opened this issue Feb 9, 2017 · 14 comments · Fixed by #1546
Closed

Force page reload in Development when external files have changed #1508

nuthinking opened this issue Feb 9, 2017 · 14 comments · Fixed by #1546
Milestone

Comments

@nuthinking
Copy link

I was wondering if there was a way to watch some local folders and force webpackHotDevClient to reload the page if a change happens. Either in default mode or ejected one. Thanks!

@Timer
Copy link
Contributor

Timer commented Feb 9, 2017

I agree this could be a useful feature, but how do we decide what to watch for changes? We'd want it to be configuration-less.

As for your local setup, you could put the npm run start behind nodemon and have it reboot the dev server for you on your specified changes. I believe it wouldn't require a manual page reload after if you're on OS X / Chrome.
This doesn't accomplish what you'd like, but will simulate it pretty well.

@gaearon
Copy link
Contributor

gaearon commented Feb 9, 2017

Can you clarify the use case? If something's in your dependency chain then refresh should already happen.

@nuthinking
Copy link
Author

To be honest, I didn't think it will be a useful feature to be implemented in the library. I am just trying to find a solution to my specific problem. Putting the npm start behind nodemon, as suggested, seems to be a plausible solution. Will test later, thanks a lot!

@Timer
Copy link
Contributor

Timer commented Feb 9, 2017

I believe his use case, or at least what I assumed it to be, was for when the public/ folder changed. e.g. changing index.html, or anything in relation to https://github.com/facebookincubator/create-react-app/blob/master/packages/react-scripts/template/README.md#when-to-use-the-public-folder.

@gaearon
Copy link
Contributor

gaearon commented Feb 9, 2017

Ideally I’d like if we could do this automatically, but not sure how easy (or efficient) that would be.

@Timer
Copy link
Contributor

Timer commented Feb 9, 2017

I believe we could use chokidar to watch the public/ directory and tell our dev-server to reboot. I don't believe there'd be a large performance implication (no different than webpack currently watching files).

@Timer Timer added this to the 0.10.0 milestone Feb 10, 2017
@gaearon
Copy link
Contributor

gaearon commented Feb 11, 2017

Maybe related: #656.

@SpaceK33z
Copy link
Contributor

webpack-dev-server has built-in support for reloading files in the contentBase. Enable with watchContentBase: true in devServer object (see docs). Maybe you guys could use that? That feature is still a bit experimental, but it should work (famous last words).

@gaearon
Copy link
Contributor

gaearon commented Feb 12, 2017

Oh that's awesome. Is it new to Webpack 2?

@SpaceK33z
Copy link
Contributor

@gaearon jup! Let me know if the feature doesn't fit your needs, perhaps we can improve the feature a bit on the dev-server side.

@gaearon
Copy link
Contributor

gaearon commented Feb 12, 2017

Cool, that should be an easy PR.

@SpaceK33z
Copy link
Contributor

Done! See #1546. Now that CRA has moved to webpack2 I will be using a forked version of create-react-app in our new company projects :).

@gaearon
Copy link
Contributor

gaearon commented Feb 13, 2017

Awesome 😄
I suspect it will take a little bit before we can cut 0.10 as we want to make a few more large changes at the same time, but we’ll likely cut an alpha soon.

Timer pushed a commit that referenced this issue Feb 15, 2017
danielfigueiredo pushed a commit to danielfigueiredo/create-react-app that referenced this issue Feb 22, 2017
kst404 pushed a commit to kst404/e8e-react-scripts that referenced this issue Mar 2, 2017
SpaceK33z added a commit to CodeYellowBV/create-react-cy-app that referenced this issue Mar 7, 2017
Resolves facebook#1508
# Conflicts:
#	packages/react-dev-utils/webpackHotDevClient.js
@gaearon
Copy link
Contributor

gaearon commented May 16, 2017

Please help beta test the new version that includes this change!
#2172

@lock lock bot locked and limited conversation to collaborators Jan 21, 2019
LishuGupta652 pushed a commit to LishuGupta652/create-react-app-1 that referenced this issue Oct 8, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants