const path = require('path');
const _ = require('lodash');
const httpProxy = require('http-proxy-middleware');

const setup = require('setup/setup');

module.exports = function() {
  const browserSync = this.context.browserSync;

  const assets = setup.assets;

  const browserSyncOpts = setup.plugins.browserSync;
  const proxyOpts = setup.plugins.httpProxyMiddleware;

  const plugins = [];
  const middleware = [];

  plugins.push({
    module: 'bs-html-injector',
    options: {
      files: [path.join(assets.build, assets.dest.docs)],
    },
  });

  _(proxyOpts.proxies).forEach((proxy) => {
    middleware.push(httpProxy(proxy.uri, proxy.options));
  });

  browserSyncOpts.plugins = plugins;
  browserSyncOpts.server.middleware = middleware;
  browserSync.init(browserSyncOpts);
};

const path = require('path');
const _ = require('lodash');
const httpProxy = require('http-proxy-middleware');

const setup = require('setup/setup');

module.exports = function(taskDone) {
  const browserSync = this.context.browserSync;

  const assets = setup.assets;

  const browserSyncOpts = setup.plugins.browserSync;
  const proxyOpts = setup.plugins.httpProxyMiddleware;

  const plugins = [];
  const middleware = [];

  plugins.push({
    module: 'bs-html-injector',
    options: {
      files: [path.join(assets.build, assets.dest.docs)],
    },
  });

  _(proxyOpts.proxies).forEach((proxy) => {
    middleware.push(httpProxy(proxy.uri, proxy.options));
  });

  browserSyncOpts.plugins = plugins;
  browserSyncOpts.server.middleware = middleware;
  browserSync.init(browserSyncOpts);
  taskDone();
};

Add task done callback on BrowserSync task
Add task done callback on BrowserSync task
