text: /**
   * Build config for electron renderer process
   */
  
  import path from 'path';
  import webpack from 'webpack';
  import MiniCssExtractPlugin from 'mini-css-extract-plugin';
  import OptimizeCSSAssetsPlugin from 'optimize-css-assets-webpack-plugin';
  import { BundleAnalyzerPlugin } from 'webpack-bundle-analyzer';
  import merge from 'webpack-merge';
  import TerserPlugin from 'terser-webpack-plugin';
  import baseConfig from './webpack.config.base';
  import CheckNodeEnv from '../internals/scripts/CheckNodeEnv';
  import DeleteSourceMaps from '../internals/scripts/DeleteSourceMaps';
  
  CheckNodeEnv('production');
  DeleteSourceMaps();
  
  export default merge.smart(baseConfig, {
    devtool: process.env.DEBUG_PROD === 'true' ? 'source-map' : 'none',
  
    mode: 'production',
  
    target: 'electron-preload',
  
    entry: path.join(__dirname, '..', 'app/index.tsx'),
  
    output: {
      path: path.join(__dirname, '..', 'app/dist'),
      publicPath: './dist/',
      filename: 'renderer.prod.js',
    },
  
    module: {
      rules: [
        {
          test: /\.(scss|less|css)$/,
          loaders: ['style-loader', 'css-loader', 'sass-loader'],
        },
  
        {
          test: /\.woff(2)?(\?v=[0-9]\.[0-9]\.[0-9])?$/,
          loader: 'url-loader?limit=10000&minetype=application/font-woff',
        },
        {
          test: /\.(ttf|eot|svg)(\?v=[0-9]\.[0-9]\.[0-9])?$/,
          loader: 'file-loader',
        },
  
        // Common Image Formats
        {
          test: /\.(?:ico|gif|png|jpg|jpeg|webp)$/,
          use: 'url-loader',
        },
      ],
    },
  
    optimization: {
      minimizer: process.env.E2E_BUILD
        ? []
        : [
            new TerserPlugin({
              parallel: true,
              sourceMap: true,
              cache: true,
            }),
            new OptimizeCSSAssetsPlugin({
              cssProcessorOptions: {
                map: {
                  inline: false,
                  annotation: true,
                },
              },
            }),
          ],
    },
  
    plugins: [
      /**
       * Create global constants which can be configured at compile time.
       *
       * Useful for allowing different behaviour between development builds and
       * release builds
       *
       * NODE_ENV should be production so that modules do not perform certain
       * development checks
       */
      new webpack.EnvironmentPlugin({
        NODE_ENV: 'production',
        DEBUG_PROD: false,
        E2E_BUILD: false,
        API_URL: 'http://localhost:3000/api',
      }),
  
      new MiniCssExtractPlugin({
        filename: 'style.css',
      }),
  
      new BundleAnalyzerPlugin({
        analyzerMode:
          process.env.OPEN_ANALYZER === 'true' ? 'server' : 'disabled',
        openAnalyzer: process.env.OPEN_ANALYZER === 'true',
      }),
    ],
  });
  