引用:webpack-dev-server藻懒、webpack-dev-middleware节榜、webpack-hot-middleware
webpack-dev-server
vi webpack.config.js
const path = require('path'); ... module.exports = { ... devServer: { contentBase: path.resolve(__dirname, './dist'), host: '192.168.0.247', compress: true, port: 8888, historyApiFallback: true, } ... }
注:
historyApiFallback
可以保證類似http://localhost:8885/aaaaaaaaaaa
的請求返回跟http://localhost:8885/
一樣的頁面,這樣才能用同一個js
根據(jù)路徑的不同去往不同的路由
vi package.json
{ ... "scripts": { ... "debug": "webpack-dev-server --mode development" ... } }
- 效果
這種方式的熱更新會刷新頁面
茫经,對react
來說,其React Tool
插件是有效的
-
webpack-dev-middleware
、webpack-hot-middleware
html-webpack-plugin
自動生成
html
html-webpack-plugin