text: ﻿const webpack = require('webpack');
  const webpackMerge = require('webpack-merge');
  const UglifyJSPlugin = require('uglifyjs-webpack-plugin');
  const MiniCssExtractPlugin = require('mini-css-extract-plugin');
  const commonConfig = require('./webpack.common.js');
  const helpers = require('./helpers');
  
  const ENV = process.env.NODE_ENV = process.env.ENV = 'production';
  
  module.exports = webpackMerge(commonConfig, {
      mode: 'production',
  
      //devtool: 'source-map', // Create map files.
  
      output: {
          path: helpers.root('./wwwroot'),
          publicPath: '',
          filename: '[name].[hash].js',
          chunkFilename: '[id].[hash].chunk.js'
      },
  
      plugins: [
          new webpack.LoaderOptionsPlugin({
              options: {
                  htmlLoader: {
                      // Workaround for ng2 (e.g. don't remove *ngFor).
                      minimize: true,
                      removeAttributeQuotes: false,
                      caseSensitive: true,
                      customAttrSurround: [[/#/, /(?:)/], [/\*/, /(?:)/], [/\[?\(?/, /(?:)/]],
                      customAttrAssign: [/\)?\]?=/]
                  }
              }
          }),
          new webpack.NoEmitOnErrorsPlugin(),
          new MiniCssExtractPlugin({
              filename: '[name].[hash].css',
              chunkFilename: '[id].css',
          }),
          new webpack.DefinePlugin({
              'process.env': {
                  'ENV': JSON.stringify(ENV)
              }
          }),
          // https://webpack.js.org/plugins/normal-module-replacement-plugin/
          new webpack.NormalModuleReplacementPlugin(
              /environments\/environment/,
              require.resolve('../environments/environment.prod.ts')
          ),
      ],
  
      optimization: {
          minimizer: [
              new UglifyJSPlugin({ // https://github.com/angular/angular/issues/10618
                  uglifyOptions: {
                      keep_fnames: true,
                  }
              })
          ]
      },
  });