"use strict";

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

var _path = _interopRequireDefault(require("path"));

var _filterPluginsAllowedForSpecficFile = require("../../../postcss/filterPluginsAllowedForSpecficFile");

var _getAllowedPostCssPlugins = require("../../../postcss/getAllowedPostCssPlugins");

var _constants = require("../../../constants");

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

// import EmptyPlugin from '../custom_postcss_plugins/EmptyPlugin';
function configPostCssLoader(options) {
  const pluginsOptions = options.css.plugins;
  const enabledPlugins = (0, _filterPluginsAllowedForSpecficFile.getEnabledPlugins)(pluginsOptions);
  const getAllowedPostCssPlugins = (0, _getAllowedPostCssPlugins.postcssPluginGetter)(options);

  function configPostCssPlugins(params) {
    const filename = _path.default.relative(_constants.appPath, params.resourcePath);

    const allowedPostCssPlugins = getAllowedPostCssPlugins(filename);
    return allowedPostCssPlugins;
  }

  return enabledPlugins.length && {
    loader: 'postcss-loader',
    options: {
      postcssOptions: configPostCssPlugins
    }
  };
}