<commit_before>const path = require('path');
const webpack = require('webpack');
const HtmlWebpackPlugin = require('html-webpack-plugin');
const OfflinePlugin = require('offline-plugin');

module.exports = {
  entry: [
    './index',
  ],
  output: {
    path: path.join(__dirname, 'dist'),
    filename: '[hash].bundle.js',
    chunkFilename: '[id].[hash].bundle.js',
    publicPath: '/',
  },
  plugins: [
    new webpack.DefinePlugin({
      'process.env.NODE_ENV': `"${process.env.NODE_ENV}"`,
    }),
    new webpack.LoaderOptionsPlugin({
      options: {
        worker: {
          output: {
            filename: "[hash].worker.js",
            chunkFilename: "[id].[hash].worker.js"
          }
        }
      }
    }),
    new HtmlWebpackPlugin({
      title: 'Cleopatra',
      template: 'res/index.html',
      favicon: 'res/favicon.png',
    }),
  ],
  resolve: {
    alias: {
      'redux-devtools/lib': path.join(__dirname, '..', '..', 'src'),
      'redux-devtools': path.join(__dirname, '..', '..', 'src'),
      'react': path.join(__dirname, 'node_modules', 'react'),
    },
    extensions: ['.js'],
  },
  module: {
    rules: [{
      test: /\.js$/,
      loaders: ['babel-loader'],
      include: __dirname,
    }, {
      test: /\.json$/,
      loaders: ['json-loader'],
      include: __dirname,
    }, {
      test: /\.css?$/,
      loaders: ['style-loader', 'css-loader?minimize'],
      include: __dirname,
    }, {
      test: /\.jpg$/,
      loader: 'file-loader',
    }, {
      test: /\.png$/,
      loader: 'file-loader',
    }, {
      test: /\.svg$/,
      loader: 'file-loader',
    }],
  },
};

if (process.env.NODE_ENV === 'production') {
  module.exports.plugins.push(
    new OfflinePlugin({
      relativePaths: false,
      AppCache: false,
      ServiceWorker: {
        scope: '/',
        navigateFallbackURL: '/',
      },
    }));
} else if (process.env.NODE_ENV === 'development') {
  module.exports.devtool = 'source-map';
  module.exports.entry = ['webpack-dev-server/client?http://localhost:4242'].concat(module.exports.entry);
}<commit_msg>Do the SPA fallback in the service worker cache lookup correctly.<commit_after>const path = require('path');
const webpack = require('webpack');
const HtmlWebpackPlugin = require('html-webpack-plugin');
const OfflinePlugin = require('offline-plugin');

module.exports = {
  entry: [
    './index',
  ],
  output: {
    path: path.join(__dirname, 'dist'),
    filename: '[hash].bundle.js',
    chunkFilename: '[id].[hash].bundle.js',
    publicPath: '/',
  },
  plugins: [
    new webpack.DefinePlugin({
      'process.env.NODE_ENV': `"${process.env.NODE_ENV}"`,
    }),
    new webpack.LoaderOptionsPlugin({
      options: {
        worker: {
          output: {
            filename: "[hash].worker.js",
            chunkFilename: "[id].[hash].worker.js"
          }
        }
      }
    }),
    new HtmlWebpackPlugin({
      title: 'Cleopatra',
      template: 'res/index.html',
      favicon: 'res/favicon.png',
    }),
  ],
  resolve: {
    alias: {
      'redux-devtools/lib': path.join(__dirname, '..', '..', 'src'),
      'redux-devtools': path.join(__dirname, '..', '..', 'src'),
      'react': path.join(__dirname, 'node_modules', 'react'),
    },
    extensions: ['.js'],
  },
  module: {
    rules: [{
      test: /\.js$/,
      loaders: ['babel-loader'],
      include: __dirname,
    }, {
      test: /\.json$/,
      loaders: ['json-loader'],
      include: __dirname,
    }, {
      test: /\.css?$/,
      loaders: ['style-loader', 'css-loader?minimize'],
      include: __dirname,
    }, {
      test: /\.jpg$/,
      loader: 'file-loader',
    }, {
      test: /\.png$/,
      loader: 'file-loader',
    }, {
      test: /\.svg$/,
      loader: 'file-loader',
    }],
  },
};

if (process.env.NODE_ENV === 'production') {
  module.exports.plugins.push(
    new OfflinePlugin({
      relativePaths: false,
      AppCache: false,
      ServiceWorker: {
        scope: '/',
      },
      cacheMaps: [
        {
          requestTypes: null,
          match: function (url, request) {
            return url.origin === location.origin ? url.origin + '/' : null;
          },
        },
      ],
    }));
} else if (process.env.NODE_ENV === 'development') {
  module.exports.devtool = 'source-map';
  module.exports.entry = ['webpack-dev-server/client?http://localhost:4242'].concat(module.exports.entry);
}
{'fraction_non_alphanumeric': 0.1974161378059837, 'fraction_numerical': 0.001813236627379873, 'mean_word_length': 2.2448529411764704, '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': '7441566', 'n_tokens_mistral': 1469, 'n_tokens_neox': 1440, 'n_words': 249}