text: const merge = require('webpack-merge');
  const UglifyJSPlugin = require('uglifyjs-webpack-plugin');
  const webpack = require('webpack');
  const MiniCssExtractPlugin = require('mini-css-extract-plugin');
  // const WorkboxPlugin = require('workbox-webpack-plugin');
  const { BundleAnalyzerPlugin } = require('webpack-bundle-analyzer');
  const autoprefixer = require('autoprefixer');
  const cssnano = require('cssnano');
  const common = require('./webpack.config.common.js');
  
  module.exports = merge(common, {
    mode: 'production',
    devtool: 'source-map',
    module: {
      rules: [
        {
          test: /\.css$/,
          use: [
            {
              loader: MiniCssExtractPlugin.loader,
            },
            'css-loader',
            {
              loader: require.resolve('postcss-loader'),
              options: {
                // Necessary for external CSS imports to work
                // https://github.com/facebookincubator/create-react-app/issues/2677
                ident: 'postcss',
                plugins: () => [
                  cssnano(),
                  autoprefixer({
                    browsers: [
                      'last 2 versions',
                      'safari >= 7',
                      'not ie < 9', // React doesn't support IE8 anyway
                    ],
                    flexbox: 'no-2009',
                  }),
                ],
              },
            },
          ],
        },
      ],
    },
    plugins: [
      new webpack.HashedModuleIdsPlugin(),
      new MiniCssExtractPlugin({
        // Options similar to the same options in webpackOptions.output
        // both options are optional
        filename: 'css/[name].[hash:8].css',
        chunkFilename: 'css/[name].[hash:8].css',
      }),
      new UglifyJSPlugin({
        sourceMap: true,
      }),
      new webpack.DefinePlugin({
        'process.env': {
          NODE_ENV: JSON.stringify('production'),
          PUBLIC_URL: JSON.stringify('https://didi.github.io/pile.js/'),
        },
      }),
      new BundleAnalyzerPlugin({
        analyzerMode: 'static',
        reportFilename: '../log/main-report.html',
      }),
      // new WorkboxPlugin.GenerateSW({
      //   // 这些选项帮助 ServiceWorkers 快速启用
      //   // 不允许遗留任何“旧的” ServiceWorkers
      //   clientsClaim: true,
      //   skipWaiting: true,
      // }),
    ],
    optimization: {
      runtimeChunk: 'single',
      splitChunks: {
        cacheGroups: {
          vendor: {
            test: /[\\/]node_modules[\\/]/,
            name: 'vendors',
            chunks: 'all',
          },
        },
      },
    },
  });
  