<commit_before>'use strict';

var glob = require('glob');
var path = require('path');
var _ = require('lodash');
var webpack = require('webpack');

module.exports = function(config) {
  var vendorChunk = 'vendors';
  var context = path.resolve(config.client.app.path);
  if (_.isString(config.client.app.buildPattern)) {
    config.client.app.buildPattern = [{
      pattern: config.client.app.buildPattern,
      splitVendor: true
    }];
  }

  var entries = _.reduce(config.client.app.buildPattern, function(memo, ruleSet) {
    _.forEach(glob.sync(ruleSet.pattern), function(file) {
      var filename = path.parse(file).name;

      memo.all[filename] = './' + path.relative(context, file);
      if (ruleSet.splitVendor) {
        memo.split.push(filename);
      }
    });

    return memo;
  }, {
    all: {},
    split: []
  });

  if (config.client.app.vendors && config.client.app.vendors.length) {
    entries.all[vendorChunk] = config.client.app.vendors;
  }

  var webpackConfig = {
    context: context,
    entry: entries.all,
    devtool: 'source-map',
    output: {
      path: config.client.app.target,
      filename: '[name].js'
    },
    module: {
      loaders: config.client.app.loaders
    },
    resolveLoader: {
      root: [ path.join(process.cwd(), 'node_modules') ]
    },
    plugins: []
  };

  if (config.client.app.vendors && config.client.app.vendors.length) {
    webpackConfig.plugins.push(
      new webpack.optimize.CommonsChunkPlugin(vendorChunk, 'vendors.js', entries.split)
    );
  }

  return webpackConfig;
};
<commit_msg>feat(webpack): buildPattern can also be a list of strings<commit_after>'use strict';

var glob = require('glob');
var path = require('path');
var _ = require('lodash');
var webpack = require('webpack');

module.exports = function(config) {
  var vendorChunk = 'vendors';
  var context = path.resolve(config.client.app.path);
  if (_.isString(config.client.app.buildPattern)) {
    config.client.app.buildPattern = [
      config.client.app.buildPattern
    ];
  }

  var entries = _.reduce(config.client.app.buildPattern, function(memo, ruleSet) {
    if (_.isString(ruleSet)) {
      ruleSet = {
        pattern: ruleSet,
        splitVendor: true
      };
    }

    _.forEach(glob.sync(ruleSet.pattern), function(file) {
      var filename = path.parse(file).name;

      memo.all[filename] = './' + path.relative(context, file);
      if (ruleSet.splitVendor) {
        memo.split.push(filename);
      }
    });

    return memo;
  }, {
    all: {},
    split: []
  });

  if (config.client.app.vendors && config.client.app.vendors.length) {
    entries.all[vendorChunk] = config.client.app.vendors;
  }

  var webpackConfig = {
    context: context,
    entry: entries.all,
    devtool: 'source-map',
    output: {
      path: config.client.app.target,
      filename: '[name].js'
    },
    module: {
      loaders: config.client.app.loaders
    },
    resolveLoader: {
      root: [ path.join(process.cwd(), 'node_modules') ]
    },
    plugins: []
  };

  if (config.client.app.vendors && config.client.app.vendors.length) {
    webpackConfig.plugins.push(
      new webpack.optimize.CommonsChunkPlugin(vendorChunk, 'vendors.js', entries.split)
    );
  }

  return webpackConfig;
};

{'fraction_non_alphanumeric': 0.1557804354492487, 'fraction_numerical': 0.0, 'mean_word_length': 2.920673076923077, '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': '322941', 'n_tokens_mistral': 1097, 'n_tokens_neox': 1081, 'n_words': 180}