text: var webpack = require('webpack');
  var path = require('path');
  var helpers = require('./helpers');
  
  var HtmlWebpackPlugin = require('html-webpack-plugin');
  var ExtractTextPlugin = require('extract-text-webpack-plugin');
  
  const ENV = process.env.NODE_ENV = process.env.ENV = 'production';
  
  module.exports = {
      devtool: 'source-map',
  
      entry: {
          'polyfills': './app/polyfills.ts',
          'vendor': './app/vendor.ts',
          'app': './app/boot.ts'
      },
  
      output: {
          path: helpers.root('dist'),
          publicPath: '/',
          filename: '[name].[hash].js',
          chunkFilename: '[id].[hash].chunk.js'
      },
  
      htmlLoader: {
          minimize: false // workaround for ng2
      },
  
      resolve: {
          extensions: ['', '.ts', '.js']
      },
  
      module: {
          loaders: [
              {
                  test: /\.ts$/,
                  exclude: path.resolve(__dirname, "node_modules"),
                  loaders: ['awesome-typescript-loader', 'angular2-template-loader', 'angular2-router-loader']
              },
              {
                  test: /\.html$/,
                  loader: 'html'
              },
              {
                  test: /\.(png|jpe?g|gif|ico)$/,
                  loader: 'file-loader?name=images/[name].[ext]'
              },
              {
                  test: /\.woff(\?v=\d+\.\d+\.\d+)?$/,
                  loader: 'url-loader?limit=10000&mimetype=application/font-woff'
              },
              {
                  test: /\.woff2(\?v=\d+\.\d+\.\d+)?$/,
                  loader: 'url-loader?limit=10000&mimetype=application/font-woff'
              },
              {
                  test: /\.ttf(\?v=\d+\.\d+\.\d+)?$/,
                  loader: 'url-loader?limit=10000&mimetype=application/octet-stream'
              },
              {
                  test: /\.eot(\?v=\d+\.\d+\.\d+)?$/,
                  loader: 'file-loader'
              },
              {
                  test: /\.svg(\?v=\d+\.\d+\.\d+)?$/,
                  loader: 'url-loader?limit=10000&mimetype=image/svg+xml'
              },
              {
                  // site wide css (excluding all css under the app dir)
                  test: /\.css$/,
                  exclude: helpers.root('app'),
                  loader: ExtractTextPlugin.extract('style', 'css?sourceMap')
              },
              {
                  // included styles under the app directory - these are for styles included
                  // with styleUrls
                  test: /\.css$/,
                  include: helpers.root('app'),
                  loader: 'raw'
              }
          ]
      },
  
      plugins: [
          new webpack.optimize.CommonsChunkPlugin({
              name: ['app', 'vendor', 'polyfills']
          }),
  
          new HtmlWebpackPlugin({
              template: 'config/index.html'
          }),
  
          new webpack.optimize.DedupePlugin(),
  
          new webpack.optimize.UglifyJsPlugin({ // https://github.com/angular/angular/issues/10618
              mangle: {
                  keep_fnames: true
              }
          }),
          new ExtractTextPlugin('[name].[hash].css'),
  
          new webpack.DefinePlugin({
              'process.env': {
                  'ENV': JSON.stringify(ENV)
              }
          })
      ]
  };