text: const path = require('path');
  const glob = require('glob');
  const MiniCssExtractPlugin = require('mini-css-extract-plugin');
  const TerserPlugin = require('terser-webpack-plugin');
  const OptimizeCSSAssetsPlugin = require('css-minimizer-webpack-plugin');
  const CopyWebpackPlugin = require('copy-webpack-plugin');
  
  module.exports = (env, options) => {
    const devMode = options.mode !== 'production';
  
    return {
      optimization: {
        minimizer: [
          new TerserPlugin({ extractComments: !devMode, parallel: true, terserOptions: { compress: !devMode } }),
          new OptimizeCSSAssetsPlugin({})
        ]
      },
      entry: {
        'app': glob.sync('./vendor/**/*.js').concat(['./js/app.js'])
      },
      output: {
        filename: '[name].js',
        path: path.resolve(__dirname, '../priv/static/js'),
        publicPath: '/js/',
        clean: true
      },
      devtool: devMode ? 'source-map' : undefined,
      module: {
        rules: [
          {
            test: /\.(woff(2)?|ttf|eot|svg)(\?v=\d+\.\d+\.\d+)?$/,
            use: [
              {
                loader: 'file-loader',
                options: { name: '[name].[ext]', outputPath: '../fonts', publicPath: '/fonts' }
              },
            ],
          },
          {
            test: /\.js$/,
            exclude: /node_modules/,
            use: {
              loader: 'babel-loader'
            }
          },
          {
            test: /\.[s]?css$/,
            use: [
              MiniCssExtractPlugin.loader,
              {
                loader: 'css-loader',
                options: {
                  url: (url, resourcePath) => {
                    if (/\.(png|jpg|jpeg|webp)?$/.test(url)) return false;
                    return true;
                  }
                }
              },
              'sass-loader',
            ],
          },
        ]
      },
      plugins: [
        new MiniCssExtractPlugin({ filename: '../css/app.css' }),
        new CopyWebpackPlugin({
          patterns: [
            { from: 'static/', to: '../' },
          ]
        })
      ]
    }
  };
  