Webpack 停止处理 ESLint 错误。
Webpack out stops working on ESLint Errors.
我不确定是什么问题。我不想打开 emitWarnings = true 因为我希望 emit 在 eslint 错误期间失败并在 eslint 错误后恢复。
修复eslint错误后如何让输出继续写入?
我尝试了以下几个选项:
https://github.com/MoOx/eslint-loader#gotchas
需要注意一点:我是运行 webpack通过Gulp.
Webpack 配置:
const webpack = require('webpack');
const path = require('path');
const glob = require('glob');
const PATHS = {
scriptApp: path.join(__dirname, '/Scripts/App'),
script: path.join(__dirname, '/Scripts/')
};
module.exports = {
entry: {
index1: [PATHS.scriptApp + '/index'],
},
devtool: 'eval-source-map',
module: {
preLoaders: [
{ test: /\.js$/, loader: 'eslint', exclude: 'node_modules' },
],
loaders: [
{ test: /\.js$/, loader: 'babel-loader', exclude: 'node_modules' },
{ test: /\.dot$/, loader: "dot-loader" }
]
},
output: {
path: path.join(__dirname, '/scripts/app/build'),
filename: '[name].bundle.js'
},
resolve: {
extensions: ['', '.js', '.dot']
},
'dust-loader-complete': {
wrapperGenerator: function (name) {return "function( context, callback ) { dust.render( '" + name + "', context, callback ); }";}
},
plugins: [
new webpack.optimize.OccurenceOrderPlugin(),
new webpack.PrefetchPlugin('jquery'),
new webpack.PrefetchPlugin('lodash'),
new webpack.ProvidePlugin({
$: 'jquery',
jquery: 'jQuery',
'windows.jQuery': 'jquery',
_: 'lodash',
toastr: 'toastr',
}),
// new webpack.optimize.UglifyJsPlugin
],
debug: true,
eslint: {
formatter: require('eslint-friendly-formatter')
}
};
Gulp 设置:
gulp.task('build-webpack', function (callback) {
webpack(webpackConfig, function(err, stats) {
if(err) throw new gutil.PluginError("webpack", err);
gutil.log("[webpack]", stats.toString({
// output options
}));
callback();
});
});
事实证明这是由于我的 gulp-配置 webpack-stream
。当 Gulp 失败时,gulp 观察者将忽略该流。我添加了 Gulp-Plumber
以防止失败。
我不确定是什么问题。我不想打开 emitWarnings = true 因为我希望 emit 在 eslint 错误期间失败并在 eslint 错误后恢复。
修复eslint错误后如何让输出继续写入?
我尝试了以下几个选项:
https://github.com/MoOx/eslint-loader#gotchas
需要注意一点:我是运行 webpack通过Gulp.
Webpack 配置:
const webpack = require('webpack');
const path = require('path');
const glob = require('glob');
const PATHS = {
scriptApp: path.join(__dirname, '/Scripts/App'),
script: path.join(__dirname, '/Scripts/')
};
module.exports = {
entry: {
index1: [PATHS.scriptApp + '/index'],
},
devtool: 'eval-source-map',
module: {
preLoaders: [
{ test: /\.js$/, loader: 'eslint', exclude: 'node_modules' },
],
loaders: [
{ test: /\.js$/, loader: 'babel-loader', exclude: 'node_modules' },
{ test: /\.dot$/, loader: "dot-loader" }
]
},
output: {
path: path.join(__dirname, '/scripts/app/build'),
filename: '[name].bundle.js'
},
resolve: {
extensions: ['', '.js', '.dot']
},
'dust-loader-complete': {
wrapperGenerator: function (name) {return "function( context, callback ) { dust.render( '" + name + "', context, callback ); }";}
},
plugins: [
new webpack.optimize.OccurenceOrderPlugin(),
new webpack.PrefetchPlugin('jquery'),
new webpack.PrefetchPlugin('lodash'),
new webpack.ProvidePlugin({
$: 'jquery',
jquery: 'jQuery',
'windows.jQuery': 'jquery',
_: 'lodash',
toastr: 'toastr',
}),
// new webpack.optimize.UglifyJsPlugin
],
debug: true,
eslint: {
formatter: require('eslint-friendly-formatter')
}
};
Gulp 设置:
gulp.task('build-webpack', function (callback) {
webpack(webpackConfig, function(err, stats) {
if(err) throw new gutil.PluginError("webpack", err);
gutil.log("[webpack]", stats.toString({
// output options
}));
callback();
});
});
事实证明这是由于我的 gulp-配置 webpack-stream
。当 Gulp 失败时,gulp 观察者将忽略该流。我添加了 Gulp-Plumber
以防止失败。