react.js - webpack配置react-hot-loader出现错误

查看:261
本文介绍了react.js - webpack配置react-hot-loader出现错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

问 题

ERROR in ./entry.js
Module build failed: Error: React Hot Loader: The Webpack loader is now exported separately. If you use Babel, we recommend that you remove "react-hot-loader" from the "loaders" section of your Webpack configuration altogether, and instead add "react-hot-loader/babel" to the "plugins" section of your .babelrc file. If you prefer not to use Babel, replace "react-hot-loader" or "react-hot" with "react-hot-loader/webpack" in the "loaders" section of your Webpack configuration.

这个是为什么。

webpack.config.js

module.exports = {
entry:'./entry.js',
output:{

path:__dirname,
filename:'bundle.js'

},
devtool:'source-map',
module:{

loaders:[
  {test:[/\.js$/,/\.jsx?$/],exclude:/(node_modules)/,loader:'react-hot!babel'},
  {test:/\.css$/,loader:'style!css'}
]

}
};

解决方案

react-hot!babel 是 react-hot=loader v1 的用法。v1 的热加载存在不少问题,现在已经发布 react-hot-loader v3,推荐使用。如果对 react-hot-loader 版本问题有疑问可参考 react 热加载方案

这篇关于react.js - webpack配置react-hot-loader出现错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆