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

changing index.html when running dev server seems doing nothing, the page only show the change after pressing refresh button . #69

Open
mizok opened this issue Jan 4, 2022 · 4 comments

Comments

@mizok
Copy link

mizok commented Jan 4, 2022

What happen?:

I cloned this repo as a template, and then I did the "npm run start" script then type a <h1>123123</h1> tag in index.html #root element, and saved the file but found nothing happened.

Expected behavior:

page should show the change right after I change and save index.html.


I found this bug in my own built boilerplate, too. so I came here to see if I can find any solution, but seems I am not lucky :(

@mizok
Copy link
Author

mizok commented Jan 4, 2022

I found that if I change the HMR setting in webpack.dev.js to false solve this problem , but this also kill the HMR :(
Just can't get any further.

@mizok
Copy link
Author

mizok commented Jan 5, 2022

Finally found the solution.
watchFiles option is needed
just add this in devServer setting

watchFiles: ['*.html']

And maybe update webpack-dev-server to @latest, since I am not sure when did those webpack DEVs create this watchFiles option

npm i -D webpack-dev-server@latest

You can check the solution here
webpack/webpack-dev-server#3794

@SimplySayHi
Copy link

@mizok in my case it doesn't work with:
watchFiles: ['*.html']

I had to use:
watchFiles: ['src/*.html']
and to watch sub-folders too, better:
watchFiles: ['src/**/*.html']

@mizok
Copy link
Author

mizok commented Jan 10, 2022

@SimplySayHi

Sure you are right. :D

That was because my entry html template file is at root of folder, in your condition it must be watchFiles: ['src/*.html'] or watchFiles: ['src/**/*.html'].

Thanks for the correction.

@mizok mizok changed the title changing index.html when running dev server seems doesn't do anything, the page only show the change after pressing refresh button . changing index.html when running dev server seems doing nothing, the page only show the change after pressing refresh button . Jan 10, 2022
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

2 participants