我使用[email protected]webpack2:配置模块规则
我的配置是非常简单的:
{
resolve: {
modules: [
SRC_ROOT,
"node_modules",
],
},
entry: "index.js",
output: {
path: sysPath.join(APP_ROOT, "dist"),
filename: "index.js",
},
module: {
rules: [
{
test: /\.js$/i,
include: SRC_ROOT,
use: [
{
loader: "eslint-loader",
enforce: "pre",
options: {
failOnError: true,
failOnWarning: true,
},
},
{
loader: "babel-loader",
}
],
}
]
},
}
当我运行它,我得到了以下内容:
Invalid configuration object. Webpack has been initialised using a configuration object that does not match the API schema.
- configuration.module.rules[0].use should be one of these:
non-empty string | function | object { loader?, options?, query? } | function | [non-empty string | function | object { loader?, options?, query? }]
Details:
* configuration.module.rules[0].use should be a string.
* configuration.module.rules[0].use should be an instance of function.
* configuration.module.rules[0].use should be an object.
* configuration.module.rules[0].use should be one of these:
non-empty string | function | object { loader?, options?, query? }
* configuration.module.rules[0].use should be an instance of function.
* configuration.module.rules[0].use[0] should be a string.
* configuration.module.rules[0].use[0] should be an instance of function.
* configuration.module.rules[0].use[0] has an unknown property 'enforce'. These properties are valid:
object { loader?, options?, query? }
* configuration.module.rules[0].use[0] should be one of these:
non-empty string | function | object { loader?, options?, query? }
我很困惑,因为这些错误与我在文档中看到的完全相反:https://webpack.js.org/configuration/#options。不支持“使用”的数组? “未知财产'执行'”?当doc显示完全相同的用法示例时,甚至有可能?
请解释我在这里做错了什么。您rules
module: {
rules: [
{
test: /\.js$/i,
include: SRC_ROOT,
loader: "eslint-loader",
enforce: "pre",
options: {
failOnError: true,
failOnWarning: true,
}
},
{
test: /\.js$/i,
include: SRC_ROOT,
loader: "babel-loader",
}
]
}
内
你可以显示你的完整配置,以及你如何使用它? –
@NitsanBaleli它是一个完整的配置。然后我运行“node_modules/.bin/webpack”。 –