<commit_before>#!/usr/bin/env node
require('../server.babel'); // babel registration (runtime transpilation for node)

var webpack = require('webpack');
var webpackConfig = require('./merge-configs');
var fs = require('fs');
// var outputStatsPath = './webpack-stats.json';

console.log('\nBuilding webpack bundle...');
webpack(webpackConfig, function(err, stats) {
  if(err) {
    console.log('Webpack build had fatal error:', err);
    return;
  }

  var options = {
    hash: true,
    version: true,
    timings: true,
    assets: true,
    chunks: false,
    colors: true
  }

  console.log('Webpack compile was successful.');

  var jsonStats = stats.toJson();
  if(jsonStats.errors.length > 0) {
    console.log('Webpack had errors.');
    options.errors = true;
  }
  if(jsonStats.warnings.length > 0) {
    console.log('Webpack had warnings.');
    options.warnings = true;
  }

  console.log(stats.toString(options));

  if(outputStatsPath) {
    fs.writeFile(outputStatsPath, JSON.stringify(stats.toJson()), function(err) {
      if(err) {
        return console.log(err);
      }

      console.log('Webpack output stats were saved to', outputStatsPath);
    });
  }
});<commit_msg>build if buildStats boolean is true<commit_after>#!/usr/bin/env node
require('../server.babel'); // babel registration (runtime transpilation for node)

var webpack = require('webpack');
var webpackConfig = require('./merge-configs');
var fs = require('fs');
var buildStats = false;

console.log('\nBuilding webpack bundle...');
webpack(webpackConfig, function(err, stats) {
  if(err) {
    console.log('Webpack build had fatal error:', err);
    return;
  }

  var options = {
    hash: true,
    version: true,
    timings: true,
    assets: true,
    chunks: false,
    colors: true
  }

  console.log('Webpack compile was successful.');

  var jsonStats = stats.toJson();
  if(jsonStats.errors.length > 0) {
    console.log('Webpack had errors.');
    options.errors = true;
  }
  if(jsonStats.warnings.length > 0) {
    console.log('Webpack had warnings.');
    options.warnings = true;
  }

  console.log(stats.toString(options));

  if(buildStats) {
    fs.writeFile('./webpack-stats.json', JSON.stringify(stats.toJson()), function(err) {
      if(err) {
        return console.log(err);
      }

      console.log('Webpack output stats were saved to', outputStatsPath);
    });
  }
});
{'fraction_non_alphanumeric': 0.1550062840385421, 'fraction_numerical': 0.0016757436112274822, 'mean_word_length': 3.36563071297989, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 7, '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': '7407391', 'n_tokens_mistral': 763, 'n_tokens_neox': 750, 'n_words': 175}