webpack-dev-server 自动刷新页面

只需要在webpack.config.js中加入devServer: { inline: true }的配置即可。
然后命令行执行如下命令就行了

webpack-dev-server --inline
Paste_Image.png

官方文档如下:
http://webpack.github.io/docs/webpack-dev-server.html#additional-configuration-options

Inline mode
To use the inline mode, either
specify --inline
on the command line.
specify devServer: { inline: true }
in your webpack.config.js

This adds the webpack-dev-server client entry point to the webpack configuration. There is no change in the URL required. Just navigate to http://«host»:«port»/«path»
.
With the above configuration: http://localhost:8080/index.html
.
Config option or command line flag needed.
Status information in the console and (briefly) in the browser’s console log.
URL changes in the app are reflected in the browser’s URL bar.

最后编辑于
©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

推荐阅读更多精彩内容