"use strict";

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

var _ManifestJsonPlugin = require("../custom_plugins/ManifestJsonPlugin");

function configManifestJsonPlugin(options) {
  const {
    enable,
    i18nManifestJson,
    licenseManifest
  } = options.manifestJson;

  if (!enable) {
    return null;
  }

  const params = [{
    outputJsonFileName: 'manifest.json',
    test: f => !/\.i18n\.js$|\.LICENSE\.txt$|\.map$/.test(f),
    needInitialEntries: true
  }];

  if (i18nManifestJson) {
    params.push({
      outputJsonFileName: 'i18nManifest.json',
      test: f => /\.i18n\.js$/g.test(f),
      needInitialEntries: false
    });
  }

  if (licenseManifest) {
    params.push({
      outputJsonFileName: 'licenseManifest.json',
      test: f => /\.LICENSE\.txt$/g.test(f),
      needInitialEntries: false
    });
  }

  return new _ManifestJsonPlugin.AddFileToManifestJson(params);
}