const path = require('path');
const webpack = require('webpack');
const ExtractTextPlugin = require('extract-text-webpack-plugin');
const HTMLWebpackPlugin = require('html-webpack-plugin');
const AotPlugin = require('@ngtools/webpack').AotPlugin;

const CLIENT = path.resolve(__dirname, 'src', 'client');
const DIST = path.resolve(__dirname, 'dist');
const INDEX = path.join(CLIENT, 'index.html');
const TSCONFIG = path.join(__dirname, 'tsconfig.json');
const APP_MODULE = path.join(CLIENT, 'app', 'app.module.ts') + '#AppModule';
const TEST_HELPERS = path.join(CLIENT, 'testing');

const config = {
  devtool: 'source-map',

  entry: {
    polyfills: './src/client/polyfills.ts',
    main: './src/client/main.ts',
  },

  output: {
    path: DIST,
    filename: '[name].[chunkhash].js',
    publicPath: '/',
  },

  resolve: {
    extensions: ['.ts', '.js'],
  },

  module: {
    rules: [
      {
        test: /\.ts$/,
        include: CLIENT,
        exclude: TEST_HELPERS,
      //  use: '@ngtools/webpack',
        use: ['awesome-typescript-loader', 'angular2-template-loader'],
      },
      {
        test: /\.component\.html$/,
        use: {
          loader: 'html-loader',
          options: {
            minimize: false,
          },
        },
      },
      {
        test: /\.component\.s?css$/,
        use: ['to-string-loader', 'css-loader', 'postcss-loader', 'sass-loader'],
      },
      {
        test: /\.s?css$/,
        exclude: /\.component\.s?css$/,
        use: ExtractTextPlugin.extract({
          use: ['css-loader', 'postcss-loader', 'sass-loader'],
          fallback: 'style-loader',
        }),
      },
    ],
  },

  plugins: [
    new webpack.NoEmitOnErrorsPlugin(),
    new webpack.DefinePlugin({
      'process.env': {
        NODE_ENV: JSON.stringify('production'),
      },
    }),
    new webpack.ContextReplacementPlugin(
      /angular(?:\\|\/)core(?:\\|\/)@angular/,
      CLIENT,
      {}
    ),
    new webpack.NamedModulesPlugin(),
    new webpack.optimize.CommonsChunkPlugin({
      name: 'vendors',
      filename: 'vendors.[chunkhash].js',
      chunks: ['main'],
      minChunks: function (module) {
        return module.context &&
          module.context.indexOf('node_modules') !== -1;
      },
    }),
    new webpack.optimize.CommonsChunkPlugin({
      name: 'manifest',
      filename: 'manifest.[chunkhash].js',
      minChunks: Infinity,
    }),
/*
    new AotPlugin({
      tsConfigPath: TSCONFIG,
      entryModule: APP_MODULE,
    }),
*/
    new webpack.optimize.UglifyJsPlugin(),
    new ExtractTextPlugin('styles.[contenthash].css'),
    new HTMLWebpackPlugin({
      template: INDEX,
    }),
  ],
};

module.exports = config;


@@ -1226,12 +1226,86 @@
 ze: 
-fals
+true,%0A            removeAttributeQuotes: false,%0A            caseSensitive: tru
 e,%0A 
@@ -1395,16 +1395,27 @@
   use: %5B
+%0A          
 'to-stri
@@ -1429,22 +1429,145 @@
 er',
- 'css-loader',
+%0A          %7B%0A            loader: 'css-loader',%0A            options: %7B%0A              minimize: true,%0A            %7D,%0A          %7D,%0A         
  'po
@@ -1572,32 +1572,42 @@
 postcss-loader',
+%0A         
  'sass-loader'%5D,
@@ -1596,32 +1596,42 @@
    'sass-loader'
+,%0A        
 %5D,%0A      %7D,%0A    
@@ -1757,29 +1757,167 @@
   use: %5B
-'css-loader',
+%0A            %7B%0A              loader: 'css-loader',%0A              options: %7B%0A                minimize: true,%0A              %7D,%0A            %7D,%0A           
  'postcs
@@ -1926,16 +1926,28 @@
 loader',
+%0A           
  'sass-l
@@ -1944,32 +1944,44 @@
    'sass-loader'
+,%0A          
 %5D,%0A          fal
@@ -3037,16 +3037,140 @@
  INDEX,%0A
+      minify: %7B%0A        collapseWhitespace: true,%0A        conservativeCollapse: true,%0A        caseSensitive: true,%0A      %7D,%0A
     %7D),%0A

Configure minification for html/css