text: const path = require('path');
  const MiniCssExtractPlugin = require('mini-css-extract-plugin');
  const webpack = require('webpack');
  const dotenv = require('dotenv');
  const autoprefixer = require('autoprefixer');
  
  dotenv.config();
  
  const isProduction = process.env.NODE_ENV === 'production';
  
  module.exports = {
    devtool: isProduction ? 'hidden-source-map' : 'cheap-source-map',
    entry: './src/frontend/index.js',
    mode: process.env.NODE_ENV,
    output: {
      path: isProduction ? path.join(process.cwd(), './src/server/public') : '/',
      filename: isProduction ? 'assets/app-[hash].js' : 'assets/app.js',
      publicPath: '/',
    },
    resolve: {
      extensions: ['.js', '.jsx'],
    },
    optimization: {
      splitChunks: {
        chunks: 'async',
        name: true,
        cacheGroups: {
          vendors: {
            name: 'vendors',
            chunks: 'all',
            reuseExistingChunk: true,
            priority: 1,
            filename: 'assets/vendor.js',
            enforce: true,
            test(module, chunks) {
              const name = module.nameForCondition && module.nameForCondition();
              return chunks.some(
                isChunks => isChunks.name !== 'vendor' &&
                  /[\\/]node_modules[\\/]/.test(name),
              );
            },
          },
        },
      },
    },
    module: {
      rules: [
        {
          test: /\.(js|jsx)$/,
          exclude: /node_modules/,
          use: {
            loader: 'babel-loader',
          },
        },
        {
          test: /\.html$/,
          use: [
            {
              loader: 'html-loader',
            },
          ],
        },
        {
          test: /\.css|.styl$/,
          use: [
            {
              loader: MiniCssExtractPlugin.loader,
            },
            'css-loader',
            'stylus-loader',
          ],
        },
      ],
    },
    devServer: {
      historyApiFallback: true,
    },
    plugins: [
      new MiniCssExtractPlugin({
        filename: 'assets/app.css',
      }),
      new webpack.HotModuleReplacementPlugin(),
      new webpack.LoaderOptionsPlugin({
        options: {
          postcss: [autoprefixer()],
        },
      }),
    ],
  };
  