text: const webpack = require('webpack')
  const merge = require('webpack-merge')
  const HtmlWebpackPlugin = require('html-webpack-plugin')
  const FriendlyErrorsPlugin = require('friendly-errors-webpack-plugin')
  const baseWebpackConfig = require('./webpack.base.conf')
  const config = require('../config')
  const utils = require('./utils')
  
  // add hot-reload related code to entry chunks
  Object.keys(baseWebpackConfig.entry).forEach(name => {
    baseWebpackConfig.entry[name] = [ './build/dev-client' ].concat(baseWebpackConfig.entry[name])
  })
  
  module.exports = merge(baseWebpackConfig, {
    mode: 'development',
    module: {
      rules: [
        utils.eslintLoader('src'),
        utils.styleLoaders({
          sourceMap: config.dev.cssSourceMap,
        }),
      ],
    },
    // cheap-module-eval-source-map is faster for development
    devtool: '#cheap-module-eval-source-map',
    optimization: {
      noEmitOnErrors: true,
    },
    node: {
      process: true,
    },
    plugins: [
      // https://github.com/glenjamin/webpack-hot-middleware#installation--usage
      new webpack.HotModuleReplacementPlugin(),
      // https://github.com/ampedandwired/html-webpack-plugin
      new HtmlWebpackPlugin({
        template: './docs/index.pug',
      }),
      new FriendlyErrorsPlugin(),
    ],
  })
  