Reputation: 1080
I'm new to React. I'm having some problems with react server. After starting the server by npm start
if I work on the source code and make some changes, I have to stop the server and restart it to make that change available on the browser. Is there anyway to make it auto compile and refresh the browser on update ? (Like nodemon
for node ?)
Upvotes: 3
Views: 13835
Reputation: 511
I had a similar (or event the same) problem and I changed starting command in the package.json
file by adding following flags: --watch --watch-poll
to the webpack-dev-server
:
{
//...
"scripts": {
"start": "webpack-dev-server --env.ENVIRONMENT=development --content-base src/ --mode development --watch --watch-poll",
// ...
}
// ...
}
Now, using npm start
and then changing src files I can see changes in the browser.
Please here https://webpack.js.org/configuration/watch/ for more options.
Upvotes: 1