"use strict";

function _objectWithoutProperties(obj, keys) { var target = {}; for (var i in obj) { if (keys.indexOf(i) >= 0) continue; if (!Object.prototype.hasOwnProperty.call(obj, i)) continue; target[i] = obj[i]; } return target; }

var path = require("path");

exports.onCreateWebpackConfig = function (_ref, pluginOptions) {
  var actions = _ref.actions,
      getConfig = _ref.getConfig;

  var hasPluginOptions = Object.keys(pluginOptions).filter(function (item) {
    return item !== "plugins";
  }).length;
  if (hasPluginOptions) {
    var plugins = pluginOptions.plugins,
        aliasOptions = _objectWithoutProperties(pluginOptions, ["plugins"]);

    actions.setWebpackConfig({
      resolve: {
        alias: aliasOptions
      }
    });
  } else {
    var config = getConfig();
    var contextSrc = path.join(config.context, "src");
    actions.setWebpackConfig({
      resolve: {
        alias: { src: contextSrc }
      }
    });
  }
};