<commit_before>const {NoEmitOnErrorsPlugin} = require("webpack");
const UglifyJsPlugin         = require("webpack/lib/optimize/UglifyJsPlugin");

const BundleAnalyzerPlugin = require("webpack-bundle-analyzer").BundleAnalyzerPlugin;
const ExtractTextPlugin    = require("extract-text-webpack-plugin");
const {root}               = require("./constants");

/**
 * The production build may or may not include the BundleAnalyzerPlugin to visualize the build
 * result and check if any of the illustrated sizes might be optimized, or if anything is missing
 * you might have expected. By default, it starts a server at port 5000. Adjust its options if required.
 *
 * At the time of writing, the plugin is used in every production build (with and without AoT),
 * except when the exemplary production server is started as well.
 * @param useAnalyzePlugin Whether the BundleAnalyzerPlugin should be used or not.
 */
module.exports = function (useAnalyzePlugin) {
  const plugins = [
    // Plugin to let the whole build fail on any error; i.e. do not tolerate these
    new NoEmitOnErrorsPlugin(),
    /**
     * Plugin to properly minify the build output
     *
     * See: http://webpack.github.io/docs/list-of-plugins.html#uglifyjsplugin
     */
    new UglifyJsPlugin({
      beautify: false,
      comments: false
    }),
    /**
     * Plugin to extract styles as css files; We're using this for the main.scss only atm.
     * This may optimize loading time in production mode since it may be cached by the browser separately.
     *
     * See: http://webpack.github.io/docs/stylesheets.html#separate-css-bundle
     */
    new ExtractTextPlugin("main.[chunkhash].css")
  ];
  if (useAnalyzePlugin) {
    plugins.push(new BundleAnalyzerPlugin({analyzerPort: 5000}));
  }

  /**
   * In general, [hash] identifies the whole build, whereas [chunkhash] identifies the particular chunk.
   * Using these is one way to simplify cache busting.
   *
   * See: http://webpack.github.io/docs/configuration.html#output-filename
   */
  return {
    output: {
      path: root("dist"),
      filename: "[name].[chunkhash].js",
      chunkFilename: "[id].chunk.[chunkhash].js"
    },
    devtool: false,
    plugins: plugins
  };
};<commit_msg>Use [contenthash] for main.css to separate it from the importing bundle.<commit_after>const {NoEmitOnErrorsPlugin} = require("webpack");
const UglifyJsPlugin         = require("webpack/lib/optimize/UglifyJsPlugin");

const BundleAnalyzerPlugin = require("webpack-bundle-analyzer").BundleAnalyzerPlugin;
const ExtractTextPlugin    = require("extract-text-webpack-plugin");
const {root}               = require("./constants");

/**
 * The production build may or may not include the BundleAnalyzerPlugin to visualize the build
 * result and check if any of the illustrated sizes might be optimized, or if anything is missing
 * you might have expected. By default, it starts a server at port 5000. Adjust its options if required.
 *
 * At the time of writing, the plugin is used in every production build (with and without AoT),
 * except when the exemplary production server is started as well.
 * @param useAnalyzePlugin Whether the BundleAnalyzerPlugin should be used or not.
 */
module.exports = function (useAnalyzePlugin) {
  const plugins = [
    // Plugin to let the whole build fail on any error; i.e. do not tolerate these
    new NoEmitOnErrorsPlugin(),
    /**
     * Plugin to properly minify the build output
     *
     * See: http://webpack.github.io/docs/list-of-plugins.html#uglifyjsplugin
     */
    new UglifyJsPlugin({
      beautify: false,
      comments: false
    }),
    /**
     * Plugin to extract styles as css files; We're using this for the main.scss only atm.
     * This may optimize loading time in production mode since it may be cached by the browser separately.
     *
     * See: http://webpack.github.io/docs/stylesheets.html#separate-css-bundle
     */
    new ExtractTextPlugin("main.[contenthash].css")
  ];
  if (useAnalyzePlugin) {
    plugins.push(new BundleAnalyzerPlugin({analyzerPort: 5000}));
  }

  /**
   * In general, [hash] identifies the whole build, whereas [chunkhash] identifies the particular chunk.
   * Using these is one way to simplify cache busting.
   *
   * See: http://webpack.github.io/docs/configuration.html#output-filename
   */
  return {
    output: {
      path: root("dist"),
      filename: "[name].[chunkhash].js",
      chunkFilename: "[id].chunk.[chunkhash].js"
    },
    devtool: false,
    plugins: plugins
  };
};
{'fraction_non_alphanumeric': 0.10249613430527943, 'fraction_numerical': 0.0035343494588027393, 'mean_word_length': 3.3413231064237774, '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': '4126284', 'n_tokens_mistral': 1291, 'n_tokens_neox': 1239, 'n_words': 440}