Open 9188 opened 6 years ago
webpack-dev-server hot:true 配合 { plugins: [ new webpack.HotModuleReplacementPlugin(), ] } 并不能实现react热加载
可以试着配合 react-transform-hmr 或者 react-hot-loader 来实现热加载 如: react-transform-hmr $ cnpm i react-transform-hmr babel-plugin-react-transform --save-dev { "presets":["react","env"], "plugins": [ ["transform-decorators-legacy"], "transform-runtime", ["import",{"style": "css","libraryName": "antd"}] ], "env": { "development": { "plugins": [["react-transform", { "transforms": [{ "transform": "react-transform-hmr", "imports": ["react"], "locals": ["module"] }] }]] } } }
webpack配置优化(1)
可以试着配合 react-transform-hmr 或者 react-hot-loader 来实现热加载 如: react-transform-hmr $ cnpm i react-transform-hmr babel-plugin-react-transform --save-dev { "presets":["react","env"], "plugins": [ ["transform-decorators-legacy"], "transform-runtime", ["import",{"style": "css","libraryName": "antd"}] ], "env": { "development": { "plugins": [["react-transform", { "transforms": [{ "transform": "react-transform-hmr", "imports": ["react"], "locals": ["module"] }] }]] } } }