【问题标题】:Webpack out stops working on ESLint Errors.Webpack out 停止处理 ESLint 错误。
【发布时间】:2016-12-08 03:48:00
【问题描述】:

我不确定问题是什么。我不想将 emitWarnings = true 设为真,因为我希望在 eslint 错误期间发出失败,并在 eslint 错误后恢复。

修复eslint错误后如何让输出继续写入?

我尝试了以下几个选项:

https://github.com/MoOx/eslint-loader#gotchas

需要注意的一点:我正在通过 Gulp 运行 webpack。

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 gulp-watch eslint webpack-watch


    【解决方案1】:

    原来这是由于我使用 webpack-stream 进行的 gulp 配置。当 Gulp 失败时,gulp watcher 会忽略流。我添加了Gulp-Plumber 以防止失败。

    【讨论】:

      猜你喜欢
      • 2023-04-06
      • 2018-09-15
      • 2012-09-18
      • 2015-06-01
      • 2014-04-17
      • 2021-05-27
      • 2018-08-22
      • 2020-04-28
      • 2023-03-08
      相关资源
      最近更新 更多