"use strict";

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

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

var _ServiceWorkerPlugin = _interopRequireDefault(require("../custom_plugins/ServiceWorkerPlugin"));

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

function configServiceWorkerPlugin(options) {
  const {
    serviceWorker
  } = options;
  const {
    publicPath
  } = options;
  const {
    chunkSplitEnable
  } = options.i18nChunkSplit;
  const {
    enableRTLSplit
  } = options.css.plugins.rtlSplit;

  if (!serviceWorker.enable) {
    return null;
  }

  const i18nFileNameTemplate = (0, _nameTemplates.nameTemplates)('i18njs', options);
  return new _ServiceWorkerPlugin.default({ ...serviceWorker,
    publicPath,
    i18nFileNameTemplate,
    chunkSplitEnable,
    enableRTLSplit,
    entryPointName: 'main'
  });
}