"use strict";

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

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

var _BundleIntegrityReport = require("../custom_plugins/BundleIntegrityReport");

function configBundleIntegrityReport(options) {
  const webpackMode = (0, _modeUtils.getWebpackMode)(options);
  const isProduction = (0, _modeUtils.isProductionMode)(webpackMode);
  const {
    enable: statsEnable
  } = options.stats;

  if (isProduction && statsEnable) {
    return new _BundleIntegrityReport.BundleIntegrityReport({
      fileName: options.stats.fileName || 'bundle-report-integrity.json',
      excludeKeysInReport: options.stats.excludeKeys || [],
      options: {
        preset: 'verbose',
        ...options.stats.options,
        assets: true,
        chunks: true,
        modules: true,
        builtAt: true,
        hash: true
      }
    });
  }

  return null;
}