gpt4 book ai didi

webpack3 jshint-loader 不起作用

转载 作者:行者123 更新时间:2023-12-02 08:42:38 24 4
gpt4 key购买 nike

我正在尝试遵循此说明 https://webpack.js.org/loaders/jshint-loader/并得到一个错误:

我的配置文件:

const path = require('path');

module.exports = {
entry: {
app: './index.js'
},
output: {
filename: 'bundle.js',
path: path.resolve(__dirname, 'dist')
},

module: {
rules: [
{
test: /\.js$/, // include .js files
enforce: "pre", // preload the jshint loader
exclude: /node_modules/, // exclude any and all files in the node_modules folder
use: [
{
loader: "jshint-loader"
}
]
}
]
},

// more options in the optional jshint object
jshint: {
// any jshint option http://www.jshint.com/docs/options/
// i. e.
camelcase: true,

// jshint errors are displayed by default as warnings
// set emitErrors to true to display them as errors
emitErrors: false,

// jshint to not interrupt the compilation
// if you want any file with jshint errors to fail
// set failOnHint to true
failOnHint: false,

// custom reporter function
reporter: function(errors) { }
}
};

错误文本:

Invalid configuration object. Webpack has been initialised using a configuration object that does not match the API schema. - configuration has an unknown property 'jshint'. These properties are valid: object { amd?, bail?, cache?, context?, dependencies?, devServer?, devtool?, entry, externals?, loader?, module?, name?, node?, output?, performance?, plugins?, prof ile?, recordsInputPath?, recordsOutputPath?, recordsPath?, resolve?, resolveLoader?, stats?, target?, watch?, watchOptions? } For typos: please correct them. For loader options: webpack 2 no longer allows custom properties in configuration.

最佳答案

他们网站上的说明似乎已经过时,因为这确实不起作用。 Github 上有一个关于此问题的未决问题。 .

此配置应该有效:

const path = require('path');

module.exports = {
entry: {
app: './index.js'
},
output: {
filename: 'bundle.js',
path: path.resolve(__dirname, 'dist')
},

module: {
rules: [{
test: /\.js$/, // include .js files
enforce: "pre", // preload the jshint loader
exclude: /node_modules/, // exclude any and all files in the node_modules folder
use: [{
loader: "jshint-loader",
// more options in the optional jshint object
options: { // ⬅ formally jshint property
camelcase: true,
emitErrors: false,
failOnHint: false
}
}]
}]
},
};

关于webpack3 jshint-loader 不起作用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/45273988/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com