colbyfayock / html-webpack-partials-plugin

🛠 Easy HTML partials for Webpack without a custom index!
MIT License
68 stars 20 forks source link

`<header>` will be replaced without `<meta charset="utf-8">` #34

Closed zjffun closed 3 years ago

zjffun commented 3 years ago
"html-webpack-partials-plugin": "^0.7.0",

Reproduction:

index.html

<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>

<body>
    <header>
        <h1>test</h1>
    </header>
    <header>
        <h1>test</h1>
    </header>
</body>

</html>

analytics.html

<div>HtmlWebpackPartialsPlugin test</div>

webpack config

  plugins: [
    new HtmlWebpackPlugin({
      filename: 'index.html',
      template: path.resolve(__dirname, 'publish/index.html'),
    }),
    new HtmlWebpackPartialsPlugin([
      {
        path: path.resolve(__dirname, 'publish/partials/analytics.html'),
        priority: 'high',
        location: 'head',
      },
    ]),
  ],

result

<!doctype html>
<html lang="en">

<head>
    <div>HtmlWebpackPartialsPlugin test</div>
    <meta charset="UTF-8" />
    <meta name="viewport" content="width=device-width,initial-scale=1">
    <title>Document</title>
</head>

<body>

    <head>
        <div>HtmlWebpackPartialsPlugin test</div>
        <h1>test</h1>

        <head>
            <div>HtmlWebpackPartialsPlugin test</div>
            <h1>test</h1>
        </head>
    </head>
</body>

</html>
zjffun commented 3 years ago

A fix #35

colbyfayock commented 3 years ago

published to v0.7.1

@all-contributors please add @zjffun for code

allcontributors[bot] commented 3 years ago

@colbyfayock

I've put up a pull request to add @zjffun! :tada: