<commit_before>const
  path           = require( 'path' ),
  webpack        = require( 'webpack' ),
  UglifyJsPlugin = require( 'uglifyjs-webpack-plugin' ),

  config  = require( './build.config' );


/**
 * Define plugins based on environment
 *
 * @param {boolean} isDev If in development mode
 *
 * @return {Array}
 */
function getPlugins( isDev ) {
  const plugins = [];

  if ( !isDev ) {
    plugins.push( new webpack.NoEmitOnErrorsPlugin());
  }

  return plugins;
}

module.exports = ({
  includeToolkit,
  includeFabricator,
} = { includeToolkit: true, includeFabricator: true }) => {
  // Add properties: { 'dests_relative_path': 'source' }
  const entries    = {},
    libraryEntries = {};

  if ( includeToolkit ) {
    entries.toolkit = `./${config.paths.toolkit.scriptsIndex}`;

    if ( !config.devMode ) entries['toolkit.min'] = `./${config.paths.toolkit.scriptsIndex}`;

    const minificationExtension = ( !config.devMode ) ? '.min' : '';

    // Add listed standalone modules and libraries to the build
    //TODO: Automate this!
    [
      'tracking',
      'popups',
      'tooltips',
      'lazyloader',
      'toolbar',
      'filtering',
      'urls',
      'core',
    ].forEach(( moduleName ) => {
      libraryEntries[`toolkit.${moduleName}${minificationExtension}`] = `./${config.paths.toolkit.scriptModules}/${moduleName}.js`;
    });
  }

  if ( includeFabricator ) {
    entries[`${config.names.fabricator.dist}/f`] = `./${config.paths.fabricator.scriptIndex}`;
  }

  return [
    {
      entry: entries,

      output: {
        path:     path.resolve( __dirname, '..', config.paths.tmp ),
        filename: '[name].js',
      },

      // (default) devtool: 'eval',

      resolve: {
        extensions: [
          '.js',
        ],
      },

      plugins: getPlugins( config.devMode ),

      mode: config.devMode ? 'development' : 'production',

      module:  {
        rules: [
          {
            test:    /\.js$/,
            exclude: /(node_modules|\.tmp|dist)/,
            loader:  'babel-loader',
          }, {
            test:   /(\.jpg|\.png)$/,
            loader: 'url-loader?limit=10000',
          },
        ],
      },

      externals: {
        jquery: 'jQuery',
      },

      optimization: {
        minimizer: [
          new UglifyJsPlugin({
            uglifyOptions: {
              output: {
                comments: false,
              },
            },
            exclude: 'toolkit.js', // Don't minify!
          }),
        ],
      },
    },

    // Config for standalone libraries compilation
    {
      entry: libraryEntries,

      output: {
        path:     path.resolve( __dirname, '..', config.paths.tmp ),
        filename: '[name].js',
      },

      // (default) devtool: 'eval',

      resolve: {
        extensions: [
          '.js',
        ],
      },

      plugins: getPlugins( config.devMode ),

      mode: config.devMode ? 'development' : 'production',

      module:  {
        rules: [
          {
            test:    /\.js$/,
            exclude: /(node_modules|\.tmp|dist)/,
            loader:  'babel-loader',
          }, {
            test:   /(\.jpg|\.png)$/,
            loader: 'url-loader?limit=10000',
          },
        ],
      },

      externals: {
        'jquery':     'jQuery',
        'cookies-js': 'Cookies',
      },

      optimization: {
        minimizer: [
          new UglifyJsPlugin({
            uglifyOptions: {
              output: {
                comments: false,
              },
            },
          }),
        ],
      },
    },
  ];

};
<commit_msg>Generate min and non min js libs<commit_after>const
  path           = require( 'path' ),
  webpack        = require( 'webpack' ),
  UglifyJsPlugin = require( 'uglifyjs-webpack-plugin' ),

  config  = require( './build.config' );


/**
 * Define plugins based on environment
 *
 * @param {boolean} isDev If in development mode
 *
 * @return {Array}
 */
function getPlugins( isDev ) {
  const plugins = [];

  if ( !isDev ) {
    plugins.push( new webpack.NoEmitOnErrorsPlugin());
  }

  return plugins;
}

module.exports = ({
  includeToolkit,
  includeFabricator,
} = { includeToolkit: true, includeFabricator: true }) => {
  // Add properties: { 'dests_relative_path': 'source' }
  const entries    = {},
    libraryEntries = {};

  if ( includeToolkit ) {
    entries.toolkit = `./${config.paths.toolkit.scriptsIndex}`;

    if ( !config.devMode ) entries['toolkit.min'] = `./${config.paths.toolkit.scriptsIndex}`;

    // const minificationExtension = ( !config.devMode ) ? '.min' : '';

    // Add listed standalone modules and libraries to the build
    //TODO: Automate this!
    [
      'tracking',
      'popups',
      'tooltips',
      'lazyloader',
      'toolbar',
      'filtering',
      'urls',
      'core',
    ].forEach(( moduleName ) => {
      libraryEntries[`toolkit.${moduleName}`] = `./${config.paths.toolkit.scriptModules}/${moduleName}.js`;
      libraryEntries[`toolkit.${moduleName}.min`] = `./${config.paths.toolkit.scriptModules}/${moduleName}.js`;
    });
  }

  if ( includeFabricator ) {
    entries[`${config.names.fabricator.dist}/f`] = `./${config.paths.fabricator.scriptIndex}`;
  }

  return [
    {
      entry: entries,

      output: {
        path:     path.resolve( __dirname, '..', config.paths.tmp ),
        filename: '[name].js',
      },

      // (default) devtool: 'eval',

      resolve: {
        extensions: [
          '.js',
        ],
      },

      plugins: getPlugins( config.devMode ),

      mode: config.devMode ? 'development' : 'production',

      module:  {
        rules: [
          {
            test:    /\.js$/,
            exclude: /(node_modules|\.tmp|dist)/,
            loader:  'babel-loader',
          }, {
            test:   /(\.jpg|\.png)$/,
            loader: 'url-loader?limit=10000',
          },
        ],
      },

      externals: {
        jquery: 'jQuery',
      },

      optimization: {
        minimizer: [
          new UglifyJsPlugin({
            uglifyOptions: {
              output: {
                comments: false,
              },
            },
            exclude: 'toolkit.js', // Don't minify!
          }),
        ],
      },
    },

    // Config for standalone libraries compilation
    {
      entry: libraryEntries,

      output: {
        path:     path.resolve( __dirname, '..', config.paths.tmp ),
        filename: '[name].js',
      },

      // (default) devtool: 'eval',

      resolve: {
        extensions: [
          '.js',
        ],
      },

      plugins: getPlugins( config.devMode ),

      mode: config.devMode ? 'development' : 'production',

      module:  {
        rules: [
          {
            test:    /\.js$/,
            exclude: /(node_modules|\.tmp|dist)/,
            loader:  'babel-loader',
          }, {
            test:   /(\.jpg|\.png)$/,
            loader: 'url-loader?limit=10000',
          },
        ],
      },

      externals: {
        'jquery':     'jQuery',
        'cookies-js': 'Cookies',
      },

      optimization: {
        minimizer: [
          new UglifyJsPlugin({
            uglifyOptions: {
              output: {
                comments: false,
              },
            },
          }),
        ],
      },
    },
  ];

};

{'fraction_non_alphanumeric': 0.16078270388615215, 'fraction_numerical': 0.002736726874657909, 'mean_word_length': 1.6122230164403144, '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': '81220', 'n_tokens_mistral': 2295, 'n_tokens_neox': 2215, 'n_words': 398}