Problem Description:
After configuring the Webpack-dev-server, modify the file and find it can be recompiled, but the browser page is not updated automatically.
For example, I added a new alert (1234) to the script, although the Webpack-dev-server was recompiled, but the browser page did not pop up 1234.
Solve:
You need to configure the Publicpath entry for output in Webpack.config.js. As shown below:
1 output: {2 // address to store after packing 3 // address to use when accessing files 4 FileName: ' js/[name].js '5 }
Explain:
Webpack official website has such a sentence: The Webpack-dev-server also takes a hint from publicPath
, using it to determine where to serve the output file S from.
This means that the Webpack-dev-server uses the address provided by the Publicpath configuration item to find the file being serviced.
And we generally think that it will find the file through the address set by path. In fact, the address of path is used to specify where to store the packaged files.
Questions about Webpack-dev-server can't be updated in time