<commit_before>const cwd = process.cwd();
const fs = require( 'fs' );
const path = require( 'path' );
const argv = require( 'yargs' );

// @TODO remove lodash dependecy
const _ = require( 'lodash' );

const WebpackDevServer = require( 'webpack-dev-server' );
const webpack = require( 'webpack' );

/**
 * Webpack super server
 */
function SuperServer( options ) {

  const configFilePath = ( options.config || 'webpack.config.js' )
  const webpackConfig = require( cwd + '/' + configFilePath );

  const compiler = webpack( webpackConfig );

  const proxySetup = {};


  if ( options.proxy ) {

    console.log( 'Proxying from ' + options.proxyPath + ' to ' + options.proxy );
    proxySetup[ options.proxyPath ] = options.proxy;

  }

  const contentBase = ( options.contentBase || 'app' );

  var server = new WebpackDevServer( compiler, {
    contentBase: contentBase,
    proxy: proxySetup,
    hot: true,
    quiet: false,
    noInfo: false,
    stats: { colors: true }
  } );

  // Setup mocks if defined
  if ( options.mockConfig ) {

    console.log( 'Mocking following routes' );

    if ( _.isArray( options.mockConfig ) ) {

      _.each( options.mockConfig, function _iterateMultipleMocks( mockFile ) {

        _buildMockRoutes( mockFile, server.app );

      });

    } else {

      _buildMockRoutes( options.mockConfig, server.app );

    }

  }

  server.listen( options.port, options.host );


  /**
   * Build mock middleware
   *
   * @param {Buffer} content Resource return content<commit_msg>feat(WebpackDevServer): add devServer options from webpack.config.js (#10)<commit_after>const cwd = process.cwd();
const fs = require( 'fs' );
const path = require( 'path' );
const argv = require( 'yargs' );

// @TODO remove lodash dependecy
const _ = require( 'lodash' );

const WebpackDevServer = require( 'webpack-dev-server' );
const webpack = require( 'webpack' );

/**
 * Webpack super server
 */
function SuperServer( options ) {

  const configFilePath = ( options.config || 'webpack.config.js' )
  const webpackConfig = require( cwd + '/' + configFilePath );

  const compiler = webpack( webpackConfig );

  const proxySetup = {};


  if ( options.proxy ) {

    console.log( 'Proxying from ' + options.proxyPath + ' to ' + options.proxy );
    proxySetup[ options.proxyPath ] = options.proxy;

  }

  const contentBase = ( options.contentBase || 'app' );

  var server = new WebpackDevServer( compiler, Object.assign( webpackConfig.devServer, {
    contentBase: contentBase,
    proxy: proxySetup,
    hot: true,
    quiet: false,
    noInfo: false,
    stats: { colors: true }
  } ) );

  // Setup mocks if defined
  if ( options.mockConfig ) {

    console.log( 'Mocking following routes' );

    if ( _.isArray( options.mockConfig ) ) {

      _.each( options.mockConfig, function _iterateMultipleMocks( mockFile ) {

        _buildMockRoutes( mockFile, server.app );

      });

    } else {

      _buildMockRoutes( options.mockConfig, server.app );

    }

  }

  server.listen( options.port, options.host );


  /**
   * Build mock middleware
   *
   * @param {Buffer} content Resource return content
{'fraction_non_alphanumeric': 0.13126796550622805, 'fraction_numerical': 0.0006387735547748323, 'mean_word_length': 3.1538461538461537, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1473516', 'n_tokens_mistral': 995, 'n_tokens_neox': 945, 'n_words': 249}