2

参考:webpack 踩坑

在练习自定义webpack配置,使用的是webpack5.x版本,然后发现热更新失效。搜索一番后,从上面的链接得到了解决方法:
package.json里的browserlist去掉。。。

// package.json
{
// ...

-  "browserslist": {
-    "production": [
-      ">0.2%",
-      "not dead",
-      "not op_mini all"
-    ],
-    "development": [
-      "last 1 chrome version",
-      "last 1 firefox version",
-      "last 1 safari version"
-    ]
-  }
}

并且,启动项目的时候用"serve": "webpack-dev-server --config build/webpack.dev.js"是不行的了,webpack5要换成这样:

- "serve": "webpack-dev-server --config build/webpack.dev.js
+ "serve": "webpack serve --config build/webpack.dev.js

ever
318 声望6 粉丝