<commit_before>const path = require('path');
const webpack = require('webpack');
const UglifyJSPlugin = require('uglifyjs-webpack-plugin');
const HTMLWebpackPlugin = require('html-webpack-plugin');
const glob = require('glob');

// Loaders handle certain extensions and apply transforms
function setupRules(env) {
  const rules = [];

  if (env.prod) {
    // TODO: If we want to add babel, uncomment this. Maybe add an IE flag to CME
    // Babelify all .js files for prod builds (except external modules)
    // rules.push({
    //   test: /\.js$/,
    //   exclude: /(node_modules|bower_components)/,
    //   use: [
    //     {
    //       loader: 'babel-loader',
    //       options: {
    //         presets: ['env']
    //       }
    //     }
    //   ]
    // });
  }

  return rules;
}

// Tell Webpack not to bundle these at all when required
// We have to add some core node libraries (fs, net, tls) because ripple-lib
// does not have browser-friendly builds
function setupExternals() {
  const externals = ['morgan', 'superagent-proxy'];

  // TODO: Bug ripple to make a browser-friendly build of ripple-lib?
  const nodeLibraries = ['fs', 'net', 'tls'];
  externals.push(...nodeLibraries);

  return externals;
}

// Used for extra processing that does not involve transpilation (e.g. minification)
function setupPlugins(env) {
  const plugins = [
    // This is for handling dynamic requires in third-party libraries
    // By default, webpack will bundle _everything_ that could possibly match the expression
    // inside a dynamic 'require'. This changes Webpack so that it bundles nothing.
    new webpack.ContextReplacementPlugin(/.*$/, /$NEVER_MATCH^/)
  ];

  if (!env.test) {
    // Create a browser.html which automatically includes BitGoJS
    plugins.push(new HTMLWebpackPlugin({ filename: 'browser.html', title: 'BitGo SDK Sandbox' }));
  }

  if (env.prod) {
    // Minimize output files in production
    plugins.push(new UglifyJSPlugin());
  }


  return plugins;
}

// Test configuration - does not bundle main code, but merges all files in test/ to single output file
function getTestConfig(env) {
  return {
    // Take everything in the test directory<commit_msg>Disable mangling for SDK browser builds<commit_after>const path = require('path');
const webpack = require('webpack');
const UglifyJSPlugin = require('uglifyjs-webpack-plugin');
const HTMLWebpackPlugin = require('html-webpack-plugin');
const glob = require('glob');

// Loaders handle certain extensions and apply transforms
function setupRules(env) {
  const rules = [];

  if (env.prod) {
    // TODO: If we want to add babel, uncomment this. Maybe add an IE flag to CME
    // Babelify all .js files for prod builds (except external modules)
    // rules.push({
    //   test: /\.js$/,
    //   exclude: /(node_modules|bower_components)/,
    //   use: [
    //     {
    //       loader: 'babel-loader',
    //       options: {
    //         presets: ['env']
    //       }
    //     }
    //   ]
    // });
  }

  return rules;
}

// Tell Webpack not to bundle these at all when required
// We have to add some core node libraries (fs, net, tls) because ripple-lib
// does not have browser-friendly builds
function setupExternals() {
  const externals = ['morgan', 'superagent-proxy'];

  // TODO: Bug ripple to make a browser-friendly build of ripple-lib?
  const nodeLibraries = ['fs', 'net', 'tls'];
  externals.push(...nodeLibraries);

  return externals;
}

// Used for extra processing that does not involve transpilation (e.g. minification)
function setupPlugins(env) {
  const plugins = [
    // This is for handling dynamic requires in third-party libraries
    // By default, webpack will bundle _everything_ that could possibly match the expression
    // inside a dynamic 'require'. This changes Webpack so that it bundles nothing.
    new webpack.ContextReplacementPlugin(/.*$/, /$NEVER_MATCH^/)
  ];

  if (!env.test) {
    // Create a browser.html which automatically includes BitGoJS
    plugins.push(new HTMLWebpackPlugin({ filename: 'browser.html', title: 'BitGo SDK Sandbox' }));
  }

  if (env.prod) {
    // Minimize output files in production
    plugins.push(new UglifyJSPlugin({
      uglifyOptions: {
        mangle: false
      }
    }));
  }


  return plugins;
}

// Test configuration - does not bundle main code, but merges all files in test/ to single output file
function getTestConfig(env) {
  return {
    // Take everything in the test directory
{'fraction_non_alphanumeric': 0.11987522281639929, 'fraction_numerical': 0.0, 'mean_word_length': 2.8698275862068967, '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': '7203363', 'n_tokens_mistral': 1329, 'n_tokens_neox': 1291, 'n_words': 455}