<commit_before>
var fs = require('fs-extra');
var path = require('path');
var webpack = require('webpack');

var SRC_DIR = path.join(__dirname, '../src/shared/');
var BUILD_DIR = path.join(__dirname, '../intermediate-builds/shared/');

if (process.env.NODE_ENV !== 'production') {
  throw new Error('Builds must have NODE_ENV=production');
}

// Empty the build directory.
fs.emptyDirSync(BUILD_DIR);

var config = {
  entry: path.join(SRC_DIR, 'js/index.js'),
  output: {
      path: path.join(BUILD_DIR, 'js'),
      filename: 'newtab.js'
  }
};

webpack(config).run((err, stats) => {
  if (err) {
    console.log('Failed to compile.', err)
    process.exit(1)
  }
  console.log('Webpack JS build complete.');
});

// Copy other files.
fs.copySync(path.join(SRC_DIR, 'iframe.html'), path.join(BUILD_DIR, 'iframe.html'));
fs.copySync(path.join(SRC_DIR, 'img'), path.join(BUILD_DIR, 'img'));

console.log('Copied shared files to intermediate build.');<commit_msg>Uglify JS.<commit_after>
var fs = require('fs-extra');
var path = require('path');
var webpack = require('webpack');

var SRC_DIR = path.join(__dirname, '../src/shared/');
var BUILD_DIR = path.join(__dirname, '../intermediate-builds/shared/');

if (process.env.NODE_ENV !== 'production') {
  throw new Error('Builds must have NODE_ENV=production');
}

// Empty the build directory.
fs.emptyDirSync(BUILD_DIR);

var config = {
  entry: path.join(SRC_DIR, 'js/index.js'),
  output: {
      path: path.join(BUILD_DIR, 'js'),
      filename: 'newtab.js'
  },
  plugins: [
    new webpack.optimize.UglifyJsPlugin({
      compress: {
        screw_ie8: true,
        warnings: false
      },
      mangle: {
        screw_ie8: true
      },
      output: {
        comments: false,
        screw_ie8: true
      }
    })
  ]
};

webpack(config).run((err, stats) => {
  if (err) {
    console.log('Failed to compile.', err)
    process.exit(1)
  }
  console.log('Webpack JS build complete.');
});

// Copy other files.
fs.copySync(path.join(SRC_DIR, 'iframe.html'), path.join(BUILD_DIR, 'iframe.html'));
fs.copySync(path.join(SRC_DIR, 'img'), path.join(BUILD_DIR, 'img'));

console.log('Copied shared files to intermediate build.');
{'fraction_non_alphanumeric': 0.1796160877513711, 'fraction_numerical': 0.0022851919561243145, 'mean_word_length': 3.63771186440678, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 5, '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': '777228', 'n_tokens_mistral': 759, 'n_tokens_neox': 760, 'n_words': 162}