title: Script not injected into second html file
body: <p>I'm working on a multi-page site using <code>webpack 5.7</code>. I've used 2 entrypoints to inject 2 different js files into separate html files, however for some reason the second entry isn't being injected into the file.</p>
  <p>So I've got <code>index.html</code> which has the bundled script working, and <code>portfolio.html</code> with doesn't have a script injected.</p>
  <p>My webpack config is shown below. can anyone help me please?</p>
  <pre><code>const path = require('path');
  const HtmlWebpackPlugin = require('html-webpack-plugin');
  const StylelintPlugin = require('stylelint-webpack-plugin');
  const { CleanWebpackPlugin } = require('clean-webpack-plugin');
  const ImageMinimizerPlugin = require('image-minimizer-webpack-plugin');
  const { extendDefaultPlugins } = require(&quot;svgo&quot;);
  const ESLintPlugin = require('eslint-webpack-plugin');
  const buildPath = path.resolve(__dirname, 'dist');
  
  module.exports = {
      entry: {
          index: './src/index.js',
          portfolio: './src/pages/portfolio/portfolio.js'
      },
      output: {
          filename: '[name]/bundle.js',
          assetModuleFilename: 'src/images/[name].ext',
          path: buildPath,
          publicPath: '/'
      },
      devServer: {
          static: path.resolve(__dirname, 'src'),
          port: 8080,
          open: true,
          hot: true
      },
      module: {
          rules: [
              {
                  test: /\.scss$/,
                  use: [
                      { loader: 'style-loader' },
                      { loader: 'css-loader' },
                      {
                          loader: 'postcss-loader', options: {
                              postcssOptions: {
                                  // postcss plugins, can be exported to postcss.config.js
                                  plugins: function () {
                                      return [
                                          require('autoprefixer')
                                      ];
                                  }
                              }
                          },
                      },
                      { loader: 'sass-loader' },
                  ]
              },
              {
                  test: /\.(gif|png|jpe?g|svg)$/i,
                  type: 'asset/resource'
              },
              {
                  test: /\.(woff(2)?|ttf|eot|svg)(\?v=\d+\.\d+\.\d+)?$/,
                  use: [
                      {
                          loader: 'file-loader',
                          options: {
                              name: '[name].[ext]',
                              outputPath: 'fonts/'
                          }
                      }
                  ]
              },
              {
                  test: /\.mp4$/,
                  use: 'file-loader?name=videos/[name].[ext]',
              },
  
          ]
      },
      optimization: {
          minimizer: [
              &quot;...&quot;,
              new ImageMinimizerPlugin({
                  minimizer: {
                      implementation: ImageMinimizerPlugin.imageminMinify,
                      options: {
                          // Lossless optimization with custom option
                          // Feel free to experiment with options for better result for you
                          plugins: [
                              [&quot;gifsicle&quot;, { interlaced: true }],
                              [&quot;jpegtran&quot;, { progressive: true }],
                              [&quot;optipng&quot;, { optimizationLevel: 5 }],
                              // Svgo configuration here https://github.com/svg/svgo#configuration
                              [
                                  &quot;svgo&quot;,
                                  {
                                      plugins: extendDefaultPlugins([
                                          {
                                              name: &quot;removeViewBox&quot;,
                                              active: false,
                                          },
                                          {
                                              name: &quot;addAttributesToSVGElement&quot;,
                                              params: {
                                                  attributes: [{ xmlns: &quot;http://www.w3.org/2000/svg&quot; }],
                                              },
                                          },
                                      ]),
                                  },
                              ],
                          ],
                      },
                  },
              }),
          ],
          runtimeChunk: 'single'
      },
      plugins: [
          new HtmlWebpackPlugin({
              template: 'src/index.html',
              inject: true,
              chunks: ['index'],
              filename: 'index.html'
          }),
          new HtmlWebpackPlugin({
              template: 'src/pages/portfolio/portfolio.html',
              inject: true,
              chunks: ['portfolio'],
              filename: 'portfolio.html'
          }),
          new StylelintPlugin({
              configFile: path.resolve(__dirname, 'stylelint.config.js'),
              context: path.resolve(__dirname, 'src/scss'),
              files: '**/*.scss',
          }),
          new CleanWebpackPlugin(),
          new ESLintPlugin({
              overrideConfigFile: path.resolve(__dirname, '.eslintrc'),
              context: path.resolve(__dirname, 'src/js'),
              files: '**/*.js',
          }),
      ]
  }
  </code></pre>