Trying to get webpack site with custom index.html to work on github pages

I’ve been using the HTMLWebpackPlugin to generate custom index.html to give me the benefit of having the index.html file in the ‘src’ folder rather than the ‘dist’ folder, and also to create multiple HTML files. However, I realized that that this prevents my Webpack sites from being hosted on Github pages. I wonder if there is a way to get around this.

The webpack.config.js file is displayed here:

const path = require('path');
const HtmlWebpackPlugin = require('html-webpack-plugin');

module.exports = {
    devServer: {
        static: './dist',
        historyApiFallback: true,
        open: true,
        compress: true,
        hot: true,
        port: 8080,
    },
    devtool: 'inline-source-map',
    entry: {
        index: {
            import: './src/index.js',
            dependOn: 'shared',
        },
        shared: 'lodash',
    },
    mode: "development",
    output: {
        filename: '[name].bundle.js',
        path: path.resolve(__dirname, 'dist'),
        clean: true,
    },
        optimization: {
        runtimeChunk: 'single',
        splitChunks: {
            chunks: 'all',
        },
    },
    plugins: [
        new HtmlWebpackPlugin({
            title: 'Custom Template',
            template: './src/index.html',
            minify: true,
        }),
    ],
    module: {
        rules: [
            {
                test: /.html$/i,
                loader: "html-loader",
            },
            {
                test: /.txt$/,
                use: 'raw-loader'
            },
            {
                test: /.css$/i,
                use: ['style-loader', 'css-loader'],
            },
            {
                test: /.(png|svg|jpg|jpeg|gif)$/i,
                type: 'asset/resource',
            },
            {
                test: /.(woff|woff2|eot|ttf|otf)$/i,
                type: 'asset/resource',
            },
            {
                test: /.(csv|tsv)$/i,
                use: ['csv-loader'],
            },
            {
                test: /.xml$/i,
                use: ['xml-loader'],
            },
            {
                test: /.js$/,
                loader: 'babel-loader',
            },
        ],
    },
};