Skip to content
This repository has been archived by the owner on Sep 28, 2020. It is now read-only.

ESLint error causing Webpack to stop watching/building #168

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

ESLint error causing Webpack to stop watching/building #168

bllfrnch opened this issue Mar 27, 2017 · 4 comments

Comments

@bllfrnch
Copy link

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
    })
  ])
}
@rumanHuq
Copy link

Currently Having the same issue.

@bezbeli
Copy link

bezbeli commented Apr 22, 2017

Would be good to have option to bypass this

@Jerry2Lemon
Copy link

Jerry2Lemon 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
Copy link
Contributor

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 as completed Oct 30, 2017
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants