jantimon/html-webpack-plugin

Double head tags get rendered

octomad opened this issue · 1 comments

Current behaviour 💣

When using the template content in the example in the README,

<html>
  <head>
    <%= htmlWebpackPlugin.tags.headTags %>
  </head>
  <body>
    <%= htmlWebpackPlugin.tags.bodyTags %>
  </body>
</html>

It generates HTML with double headTags like this

    <html>
      <head>
        <script defer src="bundle-c978e0d11d33c7b90855.js"></script>
      <script defer src="bundle-c978e0d11d33c7b90855.js"></script></head>
      <body>
        <h1>Hello World</h1>
        
      </body>
    </html>

Expected behaviour ☀️

I expect it to only have a single script tag.

Reproduction Example 👾

    mode: 'development',
    entry: './public/index.js',
    output: {
        path: __dirname + '/dist',
        filename: 'bundle-[hash].js'
    },
    module: {
        rules: [{
            test: /\.css$/,
            use: [
                'style-loader',
                'css-loader',
                'sass-loader'
            ]
        }]
    },
    plugins: [
      new HtmlWebpackPlugin({
        minify: false,
        title: 'my app',
        templateContent: ({htmlWebpackPlugin}) => `
            <html>
              <head>
                ${htmlWebpackPlugin.tags.headTags}
              </head>
              <body>
                <h1>Hello World</h1>
                ${htmlWebpackPlugin.tags.bodyTags}
              </body>
            </html>
          `, 
        filename: `index.html`
    })
]

Environment 🖥

Nevermind, I just found the inject option.