text: const path = require('path');
  const argv = require('yargs').argv;
  const MiniCssExtractPlugin = require('mini-css-extract-plugin');
  const UglifyJsPlugin = require('uglifyjs-webpack-plugin');
  const HtmlWebpackPlugin = require('html-webpack-plugin');
  const WebpackPwaManifest = require('webpack-pwa-manifest');
  const ServiceWorkerWebpackPlugin = require('serviceworker-webpack-plugin');
  const WebpackAssetsManifest = require('webpack-assets-manifest');
  const cssnano = require('cssnano');
  const autoprefixer = require('autoprefixer');
  
  const isDevelopment = argv.mode === 'development';
  const isProduction = !isDevelopment;
  const distPath = path.join(__dirname, '/build');
  
  module.exports = {
    entry: './src/Root.jsx',
    resolve: {
      extensions: ['.js', '.jsx'],
    },
    output: {
      filename: 'bundle.js',
      path: distPath,
    },
    module: {
      rules: [{
        test: /\.html$/,
        use: {
          loader: 'html-loader',
          options: {
            attrs: [
              ':data-src',
              'link:href',
            ],
          },
        },
      }, {
        test: /\.jsx?$/,
        exclude: /node_modules/,
        use: [{
          loader: 'babel-loader',
        }],
      }, {
        enforce: 'pre',
        test: /\.jsx?$/,
        exclude: [
          '/node_modules/',
        ],
        loader: 'eslint-loader',
        options: {
          emmitError: true,
          fix: true,
        },
      }, {
        test: /\.s?css$/,
        exclude: /node_modules/,
        use: [
          isDevelopment ? 'style-loader' : MiniCssExtractPlugin.loader,
          'css-loader',
          {
            loader: 'postcss-loader',
            options: {
              plugins: [
                isProduction ? cssnano : () => {},
                autoprefixer,
              ],
            },
          },
          'sass-loader',
        ],
      }, {
        test: /\.(gif|png|jpe?g|svg|ico)$/i,
        use: [{
          loader: 'file-loader',
          options: {
            name: 'images/[name][hash].[ext]',
          },
        }, {
          loader: 'image-webpack-loader',
          options: {
            mozjpeg: {
              progressive: true,
              quality: 70,
            },
          },
        },
        ],
      }, {
        test: /\.(eot|svg|ttf|woff|woff2)$/,
        use: {
          loader: 'file-loader',
          options: {
            name: 'fonts/[name][hash].[ext]',
          },
        },
      }],
    },
    plugins: [
      new MiniCssExtractPlugin({
        filename: '[name].css',
        chunkFilename: '[id].css',
      }),
      new HtmlWebpackPlugin(
        Object.assign(
          {},
          {
            inject: true,
            template: './public/index.html',
          },
          isProduction
            ? {
              minify: {
                removeComments: true,
                collapseWhitespace: true,
                removeRedundantAttributes: true,
                useShortDoctype: true,
                removeEmptyAttributes: true,
                removeStyleLinkTypeAttributes: true,
                keepClosingSlash: true,
                minifyJS: true,
                minifyCSS: true,
                minifyURLs: true,
              },
            }
            : undefined,
        ),
      ),
      new WebpackPwaManifest({
        filename: 'manifest.json',
        name: 'ROST CMS',
        short_name: 'ROST',
        description: 'ROST CMS',
        background_color: '#ffffff',
        theme_color: '#000000',
        orientation: 'any',
        start_url: '/',
        icons: [
          {
            src: path.resolve('./public/favicon.png'),
            sizes: [96, 128, 192, 256, 384, 512],
          },
        ],
      }),
      new ServiceWorkerWebpackPlugin({
        entry: path.join(__dirname, 'src/utils/service-worker.js'),
      }),
    ],
    optimization: isProduction ? {
      minimizer: [
        new UglifyJsPlugin({
          extractComments: true,
          cache: true,
          sourceMap: true,
          parallel: true,
          uglifyOptions: {
            compress: {
              inline: false,
              drop_console: true,
            },
            output: {
              comments: false,
            },
          },
        }),
      ],
    } : {},
    devServer: {
      contentBase: distPath,
      port: 3000,
      compress: true,
      open: true,
      historyApiFallback: true,
      hot: true,
    },
    devtool: isDevelopment ? 'source-map' : 'none',
  };
  