text: const webpack = require('webpack');
  const path = require('path');
  
  const sourcePath = path.join(__dirname, './client');
  const staticsPath = path.join(__dirname, './public');
  
  module.exports = function (env) {
    const nodeEnv = env && env.prod ? 'production' : 'development';
    const isProd = nodeEnv === 'production';
  
    const plugins = [
      new webpack.optimize.CommonsChunkPlugin({
        name: 'vendor',
        minChunks: Infinity,
        filename: 'vendor.bundle.js'
      }),
      new webpack.EnvironmentPlugin({
        NODE_ENV: nodeEnv,
      }),
      new webpack.NamedModulesPlugin(),
    ];
  
    if (isProd) {
      plugins.push(
        new webpack.LoaderOptionsPlugin({
          minimize: true,
          debug: false
        }),
        new webpack.optimize.UglifyJsPlugin({
          compress: {
            warnings: false,
            screw_ie8: true,
            conditionals: true,
            unused: true,
            comparisons: true,
            sequences: true,
            dead_code: true,
            evaluate: true,
            if_return: true,
            join_vars: true,
          },
          output: {
            comments: false,
          },
        })
      );
    } else {
      plugins.push(
        new webpack.HotModuleReplacementPlugin()
      );
    }
  
    return {
      devtool: isProd ? 'source-map' : 'eval',
      context: sourcePath,
      entry: {
        app: './index.js'
      },
      output: {
        path: staticsPath,
        filename: '[name].bundle.js',
      },
      module: {
        rules: [{
            test: /\.(html|js)$/,
            exclude: /node_modules/,
            use: [
              'babel-loader'
            ],
          },
          {
            test: /\.html$/,
            exclude: /node_modules/,
            use: 'svelte-loader',
          },
          {
            test: /\.css$/,
            exclude: /node_modules/,
            use: [
              'style-loader',
              'css-loader'
            ]
          },
        ],
      },
      resolve: {
        extensions: ['.webpack-loader.js', '.web-loader.js', '.loader.js', '.js', '.html'],
        modules: [
          path.resolve(__dirname, 'node_modules'),
          sourcePath
        ]
      },
  
      plugins,
  
      performance: isProd && {
        maxAssetSize: 100,
        maxEntrypointSize: 300,
        hints: 'warning',
      },
  
      stats: {
        colors: {
          green: '\u001b[32m',
        }
      },
  
      devServer: {
        contentBase: './public',
        historyApiFallback: true,
        port: 3000,
        compress: isProd,
        inline: !isProd,
        hot: !isProd,
        stats: {
          assets: true,
          children: false,
          chunks: false,
          hash: false,
          modules: false,
          publicPath: false,
          timings: true,
          version: false,
          warnings: true,
          colors: {
            green: '\u001b[32m',
          }
        },
      }
    };
  };
  