text: /* eslint-disable @typescript-eslint/no-var-requires */
  const path = require('path');
  const { CleanWebpackPlugin } = require('clean-webpack-plugin');
  const HtmlWebpackPlugin = require('html-webpack-plugin');
  const CopyWebpackPlugin = require('copy-webpack-plugin');
  const TerserPlugin = require('terser-webpack-plugin');
  const BundleAnalyzerPlugin = require('webpack-bundle-analyzer').BundleAnalyzerPlugin;
  
  const isProd = process.env.NODE_ENV === 'production';
  
  const config = {
    mode: isProd ? 'production' : 'development',
    context: path.resolve(__dirname, './src'),
    entry: './index.ts',
  
    output: {
      path: path.resolve(__dirname, 'dist'),
      filename: 'bundle.js',
    },
  
    module: {
      rules: [
        {
          test: /\.ts(x)?$/,
          exclude: /node_modules/,
          use: [
            {
              loader: 'babel-loader',
            },
            {
              loader: 'ts-loader',
            },
          ],
        },
        {
          test: /\.html$/,
          use: [
            {
              loader: 'html-loader',
            },
          ],
        },
        {
          test: /\.css$/,
          use: ['style-loader', 'css-loader'],
        },
      ],
    },
  
    resolve: {
      extensions: ['.ts', '.js'],
    },
  
    optimization: {
      minimize: true,
      minimizer: [
        new TerserPlugin({
          extractComments: false,
          terserOptions: {
            output: {
              comments: false,
            },
          },
        }),
      ],
    },
  
    plugins: [
      new CleanWebpackPlugin(),
      new HtmlWebpackPlugin({
        template: 'index.html',
        inject: true,
        title: 'Phaser Webpack Template',
        appMountId: 'app',
        filename: 'index.html',
        inlineSource: '.(js|css)$',
        minify: false,
      }),
      new CopyWebpackPlugin({
        patterns: [
          {
            from: 'assets',
            to: 'assets',
          },
        ],
      }),
      // new BundleAnalyzerPlugin(),
    ],
  
    devServer: {
      contentBase: path.join(__dirname, 'dist'),
      port: 5000,
      inline: true,
      hot: true,
      overlay: true,
    },
  };
  
  module.exports = config;
  