Webpack 4 devtool option does not work with webpack-dev-server Webpack 4 devtool option does not work with webpack-dev-server reactjs reactjs

Webpack 4 devtool option does not work with webpack-dev-server


So, after a long tried and error, I finally got help from one of webpack mainteiners.The main issue was eslint. If you load it as a loader, it creates unexpected behaviour. By deleting the eslint from webpack loaders for js you can fix that.

The webpack setup before:

// webpack v4const path = require('path');const HtmlWebpackPlugin = require('html-webpack-plugin');const WebpackMd5Hash = require('webpack-md5-hash');const CleanWebpackPlugin = require('clean-webpack-plugin');const baseConfig = {  entry: { main: './src/index.js' },  output: {    path: path.resolve(__dirname, 'dist'),    filename: '[name].[hash].js'  },  devServer: {    contentBase: './dist',    hot: true,    open: true  },  module: {    rules: [      {        test: /\.js$/,        exclude: /node_modules/,        **use: [          { loader: 'babel-loader' },          {            loader: 'eslint-loader',            options: { formatter: require('eslint/lib/formatters/stylish') }          }**        ]      }    ]  },  plugins: [    new CleanWebpackPlugin('dist'),    new HtmlWebpackPlugin({      inject: false,      hash: true,      template: './src/index.html',      filename: 'index.html'    }),    new WebpackMd5Hash()  ]};if (process.env.NODE_ENV === 'development') {  baseConfig.devtool = 'inline-source-map';}module.exports = baseConfig