"use strict";

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

var _webpackDevMiddleware = _interopRequireDefault(require("webpack-dev-middleware"));

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

function configWebpackDevMiddleware({
  publicPath,
  writeToDisk,
  enableDevCache,
  disableWatch,
  compress,
  compiler
}) {
  let webpackServerOptions = {
    logLevel: 'error',
    publicPath,
    headers: {
      'Access-Control-Allow-Origin': '*'
    },
    compress
  };

  if (enableDevCache) {
    webpackServerOptions.headers['Cache-Control'] = 'public, max-age=604800';
  }

  if (disableWatch) {
    webpackServerOptions.watchOptions = {
      ignored: /./
    };
  }

  if (writeToDisk) {
    webpackServerOptions.writeToDisk = true;
  }

  return (0, _webpackDevMiddleware.default)(compiler, webpackServerOptions);
}