text: const MiniCssExtractPlugin = require('mini-css-extract-plugin');
  const path = require('path');
  const webpack = require('webpack');
  const ManifestPlugin = require('webpack-manifest-plugin');
  const appConfig = require('../').config;
  const utils = require('../utils');
  
  const config = {
    mode: 'development',
  
    // Enable sourcemaps for debugging webpack's output.
    devtool: 'source-map',
  
    resolve: {
      extensions: ['.ts', '.tsx', '.js', '.jsx'],
      modules: [path.resolve(__dirname), 'node_modules', 'app', 'app/redux'],
    },
  
    entry: {
      app: [
        'react-hot-loader/patch',
        'webpack-hot-middleware/client?reload=true',
        './src/client.tsx',
        './src/vendor/main.ts'
      ]
    },
  
    output: {
      path: path.resolve('./build/public'),
      publicPath: '/public/',
      filename: 'js/[name].js',
      pathinfo: true
    },
  
    module: {
      rules: [
        {
          test: /\.tsx?$/,
          loader: 'babel-loader',
          exclude: /node_modules/
        },
        {
          test: /\.eot(\?.*)?$/,
          loader: 'file-loader?name=fonts/[hash].[ext]'
        },
        {
          test: /\.(woff|woff2)(\?.*)?$/,
          loader: 'file-loader?name=fonts/[hash].[ext]'
        },
        {
          test: /\.ttf(\?.*)?$/,
          loader: 'url-loader?limit=10000&mimetype=application/octet-stream&name=fonts/[hash].[ext]'
        },
        {
          test: /\.svg(\?.*)?$/,
          loader: 'url-loader?limit=10000&mimetype=image/svg+xml&name=fonts/[hash].[ext]'
        },
        {
          test: /\.(jpe?g|png|gif)$/i,
          loader: 'url-loader',
          options: {
            esModule: false,
            limit: 10000
          }
        },
        {
          test: /\.css$/,
          use: [
            appConfig.ssr ?
              {
                loader: MiniCssExtractPlugin.loader,
                options: {
                  hmr: process.env.NODE_ENV !== 'production',
                }
              } :
              'style-loader',
            'css-loader'
          ]
        }
      ]
    },
  
    plugins: [
      new webpack.LoaderOptionsPlugin({
        debug: true,
        options: {
          tslint: {
            failOnHint: true
          },
        }
      }),
      new ManifestPlugin({
        fileName: '../manifest.json'
      }),
      new webpack.DefinePlugin({
        'process.env': {
          BROWSER: JSON.stringify(true),
          NODE_ENV: JSON.stringify('development')
        }
      }),
      new webpack.HotModuleReplacementPlugin(),
      new MiniCssExtractPlugin({
        filename: 'css/[name].css'
      })
    ],
  
    optimization: {
      noEmitOnErrors: true
    }
  };
  
  utils.copySync('./src/favicon.ico', './build/public/favicon.ico', true);
  utils.copySync('./src/index.html', './build/index.html');
  
  module.exports = config;
  