text: const webpack = require('webpack');
  const webpackMerge = require('webpack-merge');
  const ExtractTextPlugin = require("extract-text-webpack-plugin");
  const Visualizer = require('webpack-visualizer-plugin');
  const MomentLocalesPlugin = require('moment-locales-webpack-plugin');
  const UglifyJSPlugin = require('uglifyjs-webpack-plugin');
  const WorkboxPlugin = require('workbox-webpack-plugin');
  const AngularCompilerPlugin = require('@ngtools/webpack').AngularCompilerPlugin;
  const path = require('path');
  
  const utils = require('./utils.js');
  const commonConfig = require('./webpack.common.js');
  
  const ENV = 'production';
  const extractCSS = new ExtractTextPlugin(`content/[name].[hash].css`);
  
  module.exports = webpackMerge(commonConfig({ env: ENV }), {
      // Enable source maps. Please note that this will slow down the build.
      // You have to enable it in UglifyJSPlugin config below and in tsconfig-aot.json as well
      // devtool: 'source-map',
      entry: {
          polyfills: './src/main/webapp/app/polyfills',
          global: './src/main/webapp/content/css/global.css',
          main: './src/main/webapp/app/app.main'
      },
      output: {
          path: utils.root('target/www'),
          filename: 'app/[name].[hash].bundle.js',
          chunkFilename: 'app/[id].[hash].chunk.js'
      },
      module: {
          rules: [{
              test: /(?:\.ngfactory\.js|\.ngstyle\.js|\.ts)$/,
              use: [ '@ngtools/webpack' ]
          },
          {
              test: /\.css$/,
              loaders: ['to-string-loader', 'css-loader'],
              exclude: /(vendor\.css|global\.css)/
          },
          {
              test: /(vendor\.css|global\.css)/,
              use: extractCSS.extract({
                  fallback: 'style-loader',
                  use: ['css-loader'],
                  publicPath: '../'
              })
          }]
      },
      optimization: {
          runtimeChunk: false,
          splitChunks: {
              cacheGroups: {
                  commons: {
                      test: /[\\/]node_modules[\\/]/,
                      name: 'vendors',
                      chunks: 'all'
                  }
              }
          },
          minimizer: [
              new UglifyJSPlugin({
                  parallel: true,
                  uglifyOptions: {
                      ie8: false,
                      // sourceMap: true, // Enable source maps. Please note that this will slow down the build
                      compress: {
                          dead_code: true,
                          warnings: false,
                          properties: true,
                          drop_debugger: true,
                          conditionals: true,
                          booleans: true,
                          loops: true,
                          unused: true,
                          toplevel: true,
                          if_return: true,
                          inline: true,
                          join_vars: true
                      },
                      output: {
                          comments: false,
                          beautify: false,
                          indent_level: 2
                      }
                  }
              })
          ]
      },
      plugins: [
          extractCSS,
          new MomentLocalesPlugin({
              localesToKeep: [
                      'en',
                      'es'
                      // jhipster-needle-i18n-language-moment-webpack - JHipster will add/remove languages in this array
                  ]
          }),
          new Visualizer({
              // Webpack statistics in target folder
              filename: '../stats.html'
          }),
          new AngularCompilerPlugin({
              mainPath: utils.root('src/main/webapp/app/app.main.ts'),
              tsConfigPath: utils.root('tsconfig-aot.json'),
              sourceMap: true
          }),
          new webpack.LoaderOptionsPlugin({
              minimize: true,
              debug: false
          }),
          new WorkboxPlugin.GenerateSW({
            clientsClaim: true,
            skipWaiting: true,
          })
      ],
      mode: 'production'
  });
  