"use strict";

Object.defineProperty(exports, "__esModule", {
  value: true
});
exports.configBundleAnalyzer = configBundleAnalyzer;

var _webpackBundleAnalyzer = require("webpack-bundle-analyzer");

var _modeUtils = require("../common/modeUtils");

/* eslint-disable no-use-before-define */
function configBundleAnalyzer(options) {
  const mode = (0, _modeUtils.getWebpackMode)(options);

  if ((0, _modeUtils.isProductionMode)(mode) && options.bundleAnalyze) {
    const bundleAnalyzerOptions = getBundleAnalyzerOptions(options);
    return new _webpackBundleAnalyzer.BundleAnalyzerPlugin(bundleAnalyzerOptions);
  }

  return null;
} // eslint-disable-next-line no-unused-vars


function getBundleAnalyzerOptions(options) {
  return {
    analyzerMode: 'static',
    generateStatsFile: true,
    openAnalyzer: false,
    statsOptions: {
      source: false,
      normal: true,
      chunks: false,
      chunkGroups: false,
      module: false,
      assets: true,
      assetsSort: 'name'
    }
  };
}