<commit_before>/* eslint-disable @typescript-eslint/no-var-requires */
/* global require, process, __dirname, module */

const path = require('path');
const { env } = require('process');
const { WebpackManifestPlugin } = require('webpack-manifest-plugin');
const MiniCssExtractPlugin = require('mini-css-extract-plugin');
const { DefinePlugin } = require('webpack');

const ASSET_PATH =
  process.env.ASSET_PATH ||
  (process.env.NODE_ENV === 'production' ? '/packs/' : 'http://localhost:3042/packs/');

const config = {
  mode: env.NODE_ENV === 'production' ? 'production' : 'development',
  output: {
    filename: 'js/[name]-[contenthash].js',
    chunkFilename: 'js/[name]-[contenthash].chunk.js',
    hotUpdateChunkFilename: 'js/[id]-[fullhash].hot-update.js',
    assetModuleFilename: 'static/[name]-[contenthash][ext][query]',
    path: path.resolve(__dirname, './public/packs'),
    publicPath: ASSET_PATH,
  },
  entry: {
    application: [
      path.resolve(__dirname, './app/javascript/packs/application.tsx'),
      path.resolve(__dirname, './app/javascript/packs/application.scss'),
    ],
  },
  devServer: {
    port: 3042,
    headers: { 'Access-Control-Allow-Origin': '*' },
    static: false,
  },
  resolve: {
    extensions: ['.js', '.mjs', '.ts', '.tsx'],
    modules: [path.resolve(__dirname, './app/javascript'), 'node_modules'],
    alias: {
      'react/jsx-dev-runtime': 'react/jsx-dev-runtime.js',
      'react/jsx-runtime': 'react/jsx-runtime.js',
    },
  },
  devtool: 'cheap-module-source-map',
  module: {
    rules: [
      {
        test: /\.tsx?$/,
        use: 'babel-loader',
        exclude: /node_modules/,
      },
      {
        test: /\.s[ac]ss$/i,
        use: [MiniCssExtractPlugin.loader, 'css-loader', 'sass-loader'],
      },
      {
        test: /\.css$/i,
        use: [MiniCssExtractPlugin.loader, 'css-loader'],
      },
      {
        test: /\.(woff|woff2|eot|ttf|otf|svg)$/i,
        type: 'asset',
      },
    ],
  },
  plugins: [
    new WebpackManifestPlugin(),
    new MiniCssExtractPlugin({
      filename: 'css/[name]-[contenthash].css',
    }),
    new DefinePlugin({
      'process.env.ASSET_PATH': JSON.stringify(ASSET_PATH),
    }),
  ],
};

if (process.env.ANALYZE_BUNDLE_SIZE) {
  const { BundleAnalyzerPlugin } = require('webpack-bundle-analyzer');
  config.plugins.push(new BundleAnalyzerPlugin());
}

module.exports = config;
<commit_msg>Expose __DEV__ variable that Apollo needs for bundle reduction<commit_after>/* eslint-disable @typescript-eslint/no-var-requires */
/* global require, process, __dirname, module */

const path = require('path');
const { env } = require('process');
const { WebpackManifestPlugin } = require('webpack-manifest-plugin');
const MiniCssExtractPlugin = require('mini-css-extract-plugin');
const { DefinePlugin } = require('webpack');

const ASSET_PATH =
  process.env.ASSET_PATH ||
  (process.env.NODE_ENV === 'production' ? '/packs/' : 'http://localhost:3042/packs/');

const config = {
  mode: env.NODE_ENV === 'production' ? 'production' : 'development',
  output: {
    filename: 'js/[name]-[contenthash].js',
    chunkFilename: 'js/[name]-[contenthash].chunk.js',
    hotUpdateChunkFilename: 'js/[id]-[fullhash].hot-update.js',
    assetModuleFilename: 'static/[name]-[contenthash][ext][query]',
    path: path.resolve(__dirname, './public/packs'),
    publicPath: ASSET_PATH,
  },
  entry: {
    application: [
      path.resolve(__dirname, './app/javascript/packs/application.tsx'),
      path.resolve(__dirname, './app/javascript/packs/application.scss'),
    ],
  },
  devServer: {
    port: 3042,
    headers: { 'Access-Control-Allow-Origin': '*' },
    static: false,
  },
  resolve: {
    extensions: ['.js', '.mjs', '.ts', '.tsx'],
    modules: [path.resolve(__dirname, './app/javascript'), 'node_modules'],
    alias: {
      'react/jsx-dev-runtime': 'react/jsx-dev-runtime.js',
      'react/jsx-runtime': 'react/jsx-runtime.js',
    },
  },
  devtool: 'cheap-module-source-map',
  module: {
    rules: [
      {
        test: /\.tsx?$/,
        use: 'babel-loader',
        exclude: /node_modules/,
      },
      {
        test: /\.s[ac]ss$/i,
        use: [MiniCssExtractPlugin.loader, 'css-loader', 'sass-loader'],
      },
      {
        test: /\.css$/i,
        use: [MiniCssExtractPlugin.loader, 'css-loader'],
      },
      {
        test: /\.(woff|woff2|eot|ttf|otf|svg)$/i,
        type: 'asset',
      },
    ],
  },
  plugins: [
    new WebpackManifestPlugin(),
    new MiniCssExtractPlugin({
      filename: 'css/[name]-[contenthash].css',
    }),
    new DefinePlugin({
      __DEV__: JSON.stringify(process.env.NODE_ENV !== 'production'),
      'process.env.ASSET_PATH': JSON.stringify(ASSET_PATH),
    }),
  ],
};

if (process.env.ANALYZE_BUNDLE_SIZE) {
  const { BundleAnalyzerPlugin } = require('webpack-bundle-analyzer');
  config.plugins.push(new BundleAnalyzerPlugin());
}

module.exports = config;

{'fraction_non_alphanumeric': 0.18862578425419954, 'fraction_numerical': 0.0036429872495446266, 'mean_word_length': 3.104651162790698, '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': '2050268', 'n_tokens_mistral': 1717, 'n_tokens_neox': 1668, 'n_words': 259}