<commit_before>const path = require('path');
const fs = require('fs');
const nodeExternals = require('webpack-node-externals');
const HtmlWebpackPlugin = require('html-webpack-plugin');

function client() {
    const views = fs.readdirSync(path.resolve(__dirname, "views"))
        .filter(file => path.extname(file) === ".html")
        .map(file => path.basename(file, ".html"));
    const scripts = fs.readdirSync(path.resolve(__dirname, "src/client"))
        .filter(file => path.extname(file) === ".ts")
        .map(file => path.basename(file, ".ts"));
    const names = views.filter(name => scripts.includes(name));

    return {
        mode: 'production',
        entry: names.reduce((e, name) =>
            ({ ...e, [name]: `./src/client/${name}.ts` }), {}),
        output: {
            filename: 'scripts/[name]-[hash].js',
            path: path.resolve(__dirname, 'dist'),
            publicPath: '/'
        },
        devtool: 'source-map',
        plugins: names.map(name => new HtmlWebpackPlugin({
            template: `views/${name}.html`,
            filename: `views/${name}.html`
        })),
        module: {
            rules: [<commit_msg>Include only the matching script in the HTML file.<commit_after>const path = require('path');
const fs = require('fs');
const nodeExternals = require('webpack-node-externals');
const HtmlWebpackPlugin = require('html-webpack-plugin');

function client() {
    const views = fs.readdirSync(path.resolve(__dirname, "views"))
        .filter(file => path.extname(file) === ".html")
        .map(file => path.basename(file, ".html"));
    const scripts = fs.readdirSync(path.resolve(__dirname, "src/client"))
        .filter(file => path.extname(file) === ".ts")
        .map(file => path.basename(file, ".ts"));
    const names = views.filter(name => scripts.includes(name));

    return {
        mode: 'production',
        entry: names.reduce((e, name) =>
            ({ ...e, [name]: `./src/client/${name}.ts` }), {}),
        output: {
            filename: 'scripts/[name]-[hash].js',
            path: path.resolve(__dirname, 'dist'),
            publicPath: '/'
        },
        devtool: 'source-map',
        plugins: names.map(name => new HtmlWebpackPlugin({
            chunks: [name],
            template: `views/${name}.html`,
            filename: `views/${name}.html`
        })),
        module: {
            rules: [
{'fraction_non_alphanumeric': 0.18684977111943404, 'fraction_numerical': 0.0, 'mean_word_length': 2.4840579710144928, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 17, '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': '2083255', 'n_tokens_mistral': 706, 'n_tokens_neox': 705, 'n_words': 142}