我使用[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」。 –