text: import webpack from "webpack";
  import path from "path";
  import HtmlWebpackPlugin from "html-webpack-plugin";
  import InterpolateHtmlPlugin from "react-dev-utils/InterpolateHtmlPlugin";
  import ExtractTextPlugin from "extract-text-webpack-plugin";
  import getClientEnvironment from "./env";
  import paths from "./paths";
  
  // Webpack uses `publicPath` to determine where the app is being served from.
  // In development, we always serve from the root. This makes config easier.
  const publicPath = "/";
  // `publicUrl` is just like `publicPath`, but we will provide it to our app
  // as %PUBLIC_URL% in `index.html` and `process.env.PUBLIC_URL` in JavaScript.
  // Omit trailing slash as %PUBLIC_PATH%/xyz looks better than %PUBLIC_PATH%xyz.
  const publicUrl = "";
  
  // Get environment variables to inject into our app.
  var env = getClientEnvironment(publicUrl);
  
  // Assert this just to be safe.
  // Development builds of React are slow and not intended for production.
  if (env["process.env"].NODE_ENV !== '"production"') {
    throw new Error("Production builds must have NODE_ENV=production.");
  }
  
  module.exports = {
    // Don't attempt to continue if there are any errors.
    bail: true,
    devtool: "source-map",
    entry: [require.resolve("./polyfills"), paths.appIndexJs],
    output: {
      path: paths.appBuild,
      publicPath: publicPath,
      // Generated JS file names (with nested folders).
      // There will be one main bundle, and one file per asynchronous chunk.
      // We don't currently advertise code splitting but Webpack supports it.
      filename: "js/[name].[chunkhash:8].js",
      chunkFilename: "js/[name].[chunkhash:8].chunk.js"
    },
    module: {
      rules: [
        {
          exclude: [/\.html$/, /\.(js|jsx)$/, /\.css$/, /\.json$/],
          use: [
            {
              loader: "url-loader",
              options: {
                limit: 10000,
                name: "media/[name].[hash:8].[ext]"
              }
            }
          ]
        },
        {
          test: /\.(js|jsx)$/,
          include: paths.appSrc,
          use: [
            {
              loader: "babel-loader",
              options: {
                cacheDirectory: true
              }
            }
          ]
        },
        {
          test: /\.css$/,
          use: ExtractTextPlugin.extract({
            fallback: "style-loader",
            use: "css-loader?minimize"
          })
        }
      ]
    },
    resolve: {
      alias: {
        Components: paths.componentsPath
      }
    },
    plugins: [
      // Makes the public URL available as %PUBLIC_URL% in index.html, e.g.:
      // <link rel="shortcut icon" href="%PUBLIC_URL%/favicon.ico">
      new InterpolateHtmlPlugin({
        PUBLIC_URL: publicUrl
        // You can pass any key-value pairs, this was just an example.
        // WHATEVER: 42 will replace %WHATEVER% with 42 in index.html.
      }),
      // Generates an `index.html` file with the <script> injected.
      new HtmlWebpackPlugin({
        inject: true,
        template: paths.appHtml,
        minify: {
          removeComments: true,
          collapseWhitespace: true,
          removeRedundantAttributes: true,
          useShortDoctype: true,
          removeEmptyAttributes: true,
          removeStyleLinkTypeAttributes: true,
          keepClosingSlash: true,
          minifyJS: true,
          minifyCSS: true,
          minifyURLs: true
        }
      }),
      // Makes some environment variables available to the JS code, for example:
      // if (process.env.NODE_ENV === 'production') { ... }. See `./env.js`.
      // It is absolutely essential that NODE_ENV was set to production here.
      // Otherwise React will be compiled in the very slow development mode.
      new webpack.DefinePlugin(env),
      // Minify the code.
      new webpack.optimize.UglifyJsPlugin({
        compress: {
          screw_ie8: true, // React doesn't support IE8
          warnings: false
        },
        mangle: {
          screw_ie8: true
        },
        output: {
          comments: false,
          screw_ie8: true
        },
        sourceMap: true
      }),
      // Note: this won't work without ExtractTextPlugin.extract(..) in `loaders`.
      new ExtractTextPlugin("css/[name].[contenthash:8].css")
    ],
    // Some libraries import Node modules but don't use them in the browser.
    // Tell Webpack to provide empty mocks for them so importing them works.
    node: {
      fs: "empty",
      net: "empty",
      tls: "empty"
    }
  };
  