text: 'use strict'
  
  const path = require('path')
  const {CleanWebpackPlugin} = require('clean-webpack-plugin')
  const HtmlWebpackPlugin = require('html-webpack-plugin')
  const webpack = require('webpack')
  const {BundleAnalyzerPlugin} = require('webpack-bundle-analyzer')
  
  module.exports = {
    mode: 'production',
    devtool: 'source-map',
    entry: {
      main: {
        import: './src/main.tsx',
        dependOn: 'shared',
      },
      shared: 'react',
    },
    module: {
      rules: [
        {
          test: /\.tsx?$/,
          loader: 'ts-loader',
          exclude: /node_modules/,
          options: {
            configFile: path.resolve(__dirname, 'tsconfig.build.json'),
          },
        },
      ],
    },
    resolve: {
      extensions: ['.tsx', '.ts', '.js'],
      alias: {
        react: require.resolve('react'),
        'react-dom': require.resolve('react-dom'),
        'styled-components': require.resolve('styled-components'),
      },
    },
    output: {
      filename: '[name].bundle.js',
      path: path.resolve(__dirname, 'dist'),
      publicPath: '/',
    },
    optimization: {
      runtimeChunk: 'single',
    },
    plugins: [
      new BundleAnalyzerPlugin({analyzerMode: 'static', openAnalyzer: false}),
      new CleanWebpackPlugin(),
      new HtmlWebpackPlugin({template: path.join(__dirname, 'src/template.html')}),
      new webpack.DefinePlugin({
        NODE_ENV: JSON.stringify(process.env.NODE_ENV || 'production'),
      }),
    ],
  }
  