Skip to content

Commit f78b89e

Browse files
committed
docs(guides): auto reload fixed in Development
In the [Development Guide under Using Watch Mode section] (https://webpack.js.org/guides/development/#using-watch-mode) the content says: >The only downside is that you have to refresh your browser in order to see the changes. It would be much nicer if that would happen automatically as well, so let's try webpack-dev-server which will do exactly that. The follow-on section about webpack-dev-server is expected to provide guidance about creating a setup that would reload new code as it is written and refresh the browser to show the changes. But the code example doesnot do so. The problem is in the webpack.config.js code example. The devServer configuration as mentioned will not refresh the browser. To actually refresh the page the minimum configuration that needs to be added to devServer is `watchFiles: ['./src/**/*.*']` Fixes: webpack/webpack#15477
1 parent 0fdfbf5 commit f78b89e

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

src/content/guides/development.mdx

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ contributors:
1616
- chenxsan
1717
- maxloh
1818
- snitin315
19+
- avishek143
1920
---
2021

2122
T> This guide extends on code examples found in the [Output Management](/guides/output-management) guide.
@@ -214,6 +215,7 @@ Change your configuration file to tell the dev server where to look for files:
214215
devtool: 'inline-source-map',
215216
+ devServer: {
216217
+ static: './dist',
218+
+ watchFiles: ['./src/**/*.*'],
217219
+ },
218220
plugins: [
219221
new HtmlWebpackPlugin({
@@ -228,7 +230,7 @@ Change your configuration file to tell the dev server where to look for files:
228230
};
229231
```
230232

231-
This tells `webpack-dev-server` to serve the files from the `dist` directory on `localhost:8080`.
233+
This tells `webpack-dev-server` to serve the files from the `dist` directory on `localhost:8080` and refresh the browser with the new content when any source file inside the `./src` folder changes.
232234

233235
T> `webpack-dev-server` serves bundled files from the directory defined in [`output.path`](/configuration/output/#outputpath), i.e., files will be available under `http://[devServer.host]:[devServer.port]/[output.publicPath]/[output.filename]`.
234236

0 commit comments

Comments
 (0)