我从复数课程学习webpack。我使用的是作者的package.json文件。
如果我只运行webpack命令就可以正常运行。
如果我运行webpack-dev-server,我会得到以下内容:
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.
这是我的webpack.config.js:
module.exports = {
entry: ["./utils", "./app.js"],
output: {
filename: "bundle.js"
},
module: {
preLoaders: [
{
test: /\.js$/,
exclude: 'node_modules',
loader: 'jshint-loader'
}
],
loaders: [
{
test: /\.es6$/,
exclude: /node_modules/,
loader: "babel-loader"
}
]
},
resolve: {
extensions: ['', '.js', '.es6']
}
}
我的package.json:
"devDependencies": {
"babel-core": "^6.2.1",
"babel-loader": "^6.2.0",
"babel-preset-es2015": "^6.1.18",
"jshint": "^2.8.0",
"jshint-loader": "^0.8.3",
"node-libs-browser": "^0.5.3",
"webpack": "^1.12.9"
}
答案 0 :(得分:2)
您尝试使用webpack1的配置运行webpack2 - 您需要确保全局安装了webpack1,因为您的课程是在webpack1上 - 而不是webpack 2
答案 1 :(得分:2)
如果您想坚持使用Webpack 2,您可以更新您的webpack.config.js
你不需要Webpack 2中的空扩展名,所以你在哪里
resolve: {
extensions: ['', '.js', '.es6']
}
需要更改为:
resolve: {
extensions: ['.js', '.es6']
}