"use strict";

var _Object$defineProperty = require("@babel/runtime-corejs3/core-js-stable/object/define-property");

var _interopRequireDefault = require("@babel/runtime-corejs3/helpers/interopRequireDefault");

_Object$defineProperty(exports, "__esModule", {
  value: true
});

exports.default = void 0;

var _asyncToGenerator2 = _interopRequireDefault(require("@babel/runtime-corejs3/helpers/asyncToGenerator"));

var _plugin = _interopRequireDefault(require("@start/plugin"));

var _pluginSequence = _interopRequireDefault(require("@start/plugin-sequence"));

var _pluginRemove = _interopRequireDefault(require("@start/plugin-remove"));

var _pluginFind = _interopRequireDefault(require("@start/plugin-find"));

var _pluginLibWebpack = _interopRequireDefault(require("@start/plugin-lib-webpack"));

var _webpack = require("../../configs/webpack/webpack.plugins");

var _default = locals => (0, _plugin.default)('BUILD APP', ({
  reporter
}) => /*#__PURE__*/(0, _asyncToGenerator2.default)(function* () {
  const webpackConfig = require('../../configs/webpack/webpack.config.production');

  if (locals) {
    const regex = new RegExp(locals.join('|'));
    webpackConfig.plugins.push(new _webpack.ContextReplacementPlugin(/moment[/\\]locale$/, regex));
  }

  try {
    return (0, _pluginSequence.default)((0, _pluginFind.default)(webpackConfig.output.path), _pluginRemove.default, (0, _pluginLibWebpack.default)(webpackConfig, {
      chunks: false,
      modules: false,
      hash: false,
      timings: false
    }))(reporter)();
  } catch (e) {
    reporter.emit('error', e);
    process.exit(1);
  }
}));

exports.default = _default;
module.exports = exports.default;