webpack "webpack-dev-server --hot"报错,球解答
1.webpack初学者,在倒腾配置环境,在启动的时候遇见了如下个问题,下面是报错信息:
➜ webpack-react npm run dev
> webpack-react@1.0.0 dev /Users/one/webpack-react
> webpack-dev-server --hot
Invalid configuration object. Webpack has been initialised using a configuration object that does not match the API schema.
- configuration.module has an unknown property 'preLoaders'. These properties are valid:
object { exprContextCritical?, exprContextRecursive?, exprContextRegExp?, exprContextRequest?, loaders?, noParse?, rules?, unknownContextCritical?, unknownContextRecursive?, unknownContextRegExp?, unknownContextRequest?, unsafeCache?, wrappedContextCritical?, wrappedContextRecursive?, wrappedContextRegExp? }
Options affecting the normal modules (`NormalModuleFactory`).
- configuration.resolve.extensions[0] should not be empty.
2.下面是我的配置文件
var path = require('path');
var webpack = require('webpack');
var HtmlwebpackPlugin = require('html-webpack-plugin');
//一些常用路径
var ROOT_PATH = path.resolve(__dirname);
var APP_PATH = path.resolve(ROOT_PATH,'app');
var BULID_PATH = path.resolve(ROOT_PATH,'bulid');
module.exports = {
entry: {
app: path.resolve(APP_PATH,'index.jsx')
},
output: {
path: BULID_PATH,
filename: 'bundle.js'
},
//开启dev source map
devtool:'eval-source-map',
//开启webpack dev server
devServer: {
historyApiFallback: true,
hot: true,
inline: true,
progress: true
},
module: {
//配置preLoaders,将eslint添加进入
preLoaders: [
{
test: /\.jsx?$/,
loaders: ['eslint'],
include: APP_PATH
}
],
//配置loader,将Babel添加进去
loaders: [
{
test: /\.jsx?$/,
loaders: ['babel'],
include: APP_PATH
}
]
},
resolve:{
extensions:['','.js','jsx']
},
plugins: [
new HtmlwebpackPlugin({
title: 'My first react app'
})
]
};
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
用的是 webpack 2.x ? 没有 preLoders 选项了。
详细 https://doc.webpack-china.org...
我现在也遇到一样的问题 是看 react 全栈那本书看到的,然后把 preLoders 去掉也还是会有报错.我只能把package.json 里面的数据换成和其一样的才好使.问下楼主有没有其他的解决办法