"use strict";

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

var _nameTemplates = require("../common/nameTemplates");

var _I18nSplitPlugin = _interopRequireDefault(require("../custom_plugins/I18nSplitPlugin"));

var _resourceBasedPublicPath = require("../common/resourceBasedPublicPath");

function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }

function configI18nSplitPlugin(options) {
  const {
    i18nChunkSplit
  } = options;

  if (!i18nChunkSplit.chunkSplitEnable) {
    return null;
  }

  const i18nPublicPath = (0, _resourceBasedPublicPath.resourceBasedPublicPath)('i18n', options); // const i18nPublicPathAsExpression  = publicPathAsExpression('i18n', options);

  return new _I18nSplitPlugin.default({
    mainChunkName: 'main',
    jsResource: i18nChunkSplit.jsResource,
    localeVarName: i18nChunkSplit.localeVarName,
    jsonpFunc: i18nChunkSplit.jsonpFunc,
    templateLabel: i18nChunkSplit.templateLabel,
    disableDefault: i18nChunkSplit.disableDefault,
    filename: (0, _nameTemplates.nameTemplates)('i18njs', options),
    chunkFilename: (0, _nameTemplates.nameTemplates)('i18nchunkjs', options),
    publicPath: i18nPublicPath,
    i18nManifestFileName: (0, _nameTemplates.nameTemplates)('i18nmanifest', options),
    // template: (object, locale) => `window.loadI18n(${JSON.stringify(object)}, ${JSON.stringify(locale)})`,
    propertiesFolder: i18nChunkSplit.propertiesFolder
  });
}