New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ESLint error causing Webpack to stop watching/building #168

Closed
bllfrnch opened this Issue Mar 27, 2017 · 4 comments

Comments

Projects
None yet
5 participants
@bllfrnch

bllfrnch commented Mar 27, 2017

Hi, whenever my Webpack build encounters an ESLint error while running in watch mode, it reports the error it encountered and hangs. Successive updates to the files in the source tree are not built by Webpack. Any idea why this might be happening?

  • eslint version: 3.15.0
  • eslint-loader version: 1.6.1
  • webpack version: 2.2.1

Thanks in advance for any help you may be able to offer.

Webpack config follows.

const path = require('path'),
    ExtractTextPlugin = require('extract-text-webpack-plugin'),
    StyleLintPlugin = require('stylelint-webpack-plugin'),
    // CopyWebpackPlugin = require('copy-webpack-plugin'),
    HtmlWebpackPlugin = require('html-webpack-plugin'),
    webpack = require('webpack');

const sassLoader = {
  loader: 'sass-loader',
  options: {
    includePaths: [path.resolve(__dirname, 'node_modules')]
  }
};

let config = path.join(__dirname, 'config', process.env.NODE_ENV);

module.exports = {
  entry: {
    main: './src/main.js'
  },
  output: {
    filename: 'js/[name].[chunkhash].js',
    path: path.resolve(__dirname, 'build'),
  },
  module: {
    rules: [
      {
        enforce: 'pre',
        test: /.vue$|.js$/,
        loader: 'eslint-loader',
        exclude: /node_modules/
      },
      {
        test: /\.vue$/,
        use: {
          loader: 'vue-loader',
          options: {
            loaders: {
              css: ExtractTextPlugin.extract({
                use: ['css-loader', 'postcss-loader'],
                fallback: 'vue-style-loader' // <- this is a dep of vue-loader, so no need to explicitly install if using npm3
              }),
              scss: ExtractTextPlugin.extract({
                use: ['css-loader', 'postcss-loader', sassLoader]
              }),
              sass: ExtractTextPlugin.extract({
                use: ['css-loader', 'postcss-loader', sassLoader]
              }),
            }
            // other vue-loader options go here
          }
        }
      },
      {
        test: /\.js$/,
        use: 'babel-loader',
        exclude: /node_modules/
      },
      {
        test: /\.(png|jpg|gif|svg)$/,
        use: {
          loader: 'file-loader',
          options: {
            name: '[name].[ext]?[hash]'
          }
        }
      },
      {
        test: /\.scss$|\.css$/,
        loader: ExtractTextPlugin.extract({
          //fallback: 'style-loader',
          use: ['css-loader', 'postcss-loader', sassLoader]
        })
      }
    ]
  },
  resolve: {
    alias: {
      'vue$': 'vue/dist/vue.common.js',
      'node_modules': path.resolve(__dirname, 'node_modules'),
      'lib': path.resolve(__dirname, 'src/lib'),
      'components': path.resolve(__dirname, 'src/components'),
      'scss': path.resolve(__dirname, 'src/scss'),
      'config': config
    }
  },
  devServer: {
    historyApiFallback: true,
    noInfo: true
  },
  performance: {
    hints: "warning"
  },
  devtool: '#source-map',
  plugins: [
    new webpack.optimize.CommonsChunkPlugin({
      name: 'vendor',
      minChunks: function (module) {
        // this assumes your vendor imports exist in the node_modules directory
        return module.context && module.context.indexOf('node_modules') !== -1;
      }
    }),
    new HtmlWebpackPlugin({
      filename: 'index.html',
      template: '!!ejs-loader!' + __dirname + '/src/assets/index.ejs',
      webHost: require(config).webHost
    }),
    new ExtractTextPlugin({
      filename: 'css/[name].[chunkhash].css',
      disable: false,
      allChunks: true
    }),
    new StyleLintPlugin({
      configFile: '.stylelintrc',
      context: __dirname + '/src',
      files: ['**/*.s?(a|c)ss', '**/*.vue'],
      syntax: 'scss'
    }),
    // new CopyWebpackPlugin([
    //   {
    //     context: './src/assets',
    //     from: {
    //       glob: '**/*',
    //       dot: false
    //     },
    //     to: __dirname + '/build'
    //   }
    // ])
  ]
};

if (process.env.NODE_ENV === 'production') {
  // module.exports.devtool = '';
  // http://vue-loader.vuejs.org/en/workflow/production.html
  module.exports.plugins = (module.exports.plugins || []).concat([
    new webpack.DefinePlugin({
      'process.env': {
        NODE_ENV: '"production"'
      }
    }),
    new webpack.optimize.UglifyJsPlugin({
      sourceMap: true,
      compress: {
        warnings: false
      }
    }),
    new webpack.LoaderOptionsPlugin({
      minimize: true
    })
  ])
}
@rumanbsl

This comment has been minimized.

rumanbsl commented Apr 10, 2017

Currently Having the same issue.

@bezbeli

This comment has been minimized.

bezbeli commented Apr 22, 2017

Would be good to have option to bypass this

@bobossy

This comment has been minimized.

bobossy commented Apr 23, 2017

Having the same issue. Eslint error cause the webpack stop.
webpack 2.4.1
eslint 3.19.0
eslint-loader 1.7.1 use default config

#148 shssoichiro provides a workaround, like this:

rules: [{
  enforce: 'pre',
  test: /\.jsx?$/,
  exclude: /(node_modules|bower_components)/,
  loader: 'eslint-loader',
  options: {
    emitWarning: true
  }
}]

mehigh added a commit to xwp/fe-dev-lib that referenced this issue Aug 1, 2017

@MoOx

This comment has been minimized.

Member

MoOx commented Oct 30, 2017

By default Eslint errors will raise webpack errors unless you change the config as shown above.

@MoOx MoOx closed this Oct 30, 2017

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment