{"id":13451821,"url":"https://github.com/jantimon/html-webpack-plugin","last_synced_at":"2025-05-13T11:06:37.611Z","repository":{"id":19498295,"uuid":"22744595","full_name":"jantimon/html-webpack-plugin","owner":"jantimon","description":"Simplifies creation of HTML files to serve your webpack bundles","archived":false,"fork":false,"pushed_at":"2024-10-23T00:57:10.000Z","size":1936,"stargazers_count":10736,"open_issues_count":42,"forks_count":1302,"subscribers_count":118,"default_branch":"main","last_synced_at":"2025-05-05T20:52:26.428Z","etag":null,"topics":["html-webpack-plugin","webpack"],"latest_commit_sha":null,"homepage":"","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/jantimon.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":".github/FUNDING.yml","license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null},"funding":{"github":null,"patreon":null,"open_collective":"html-webpack-plugin","ko_fi":null,"tidelift":null,"community_bridge":null,"liberapay":null,"issuehunt":null,"otechie":null,"custom":null}},"created_at":"2014-08-08T03:19:15.000Z","updated_at":"2025-05-04T15:24:49.000Z","dependencies_parsed_at":"2023-09-29T08:50:51.790Z","dependency_job_id":"0abd1c25-fa26-4d95-b126-f707f9aec451","html_url":"https://github.com/jantimon/html-webpack-plugin","commit_stats":{"total_commits":756,"total_committers":181,"mean_commits":4.176795580110498,"dds":"0.44179894179894175","last_synced_commit":"7299866767d7256c65e1d11daaed83426b6d74aa"},"previous_names":["ampedandwired/html-webpack-plugin"],"tags_count":91,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jantimon%2Fhtml-webpack-plugin","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jantimon%2Fhtml-webpack-plugin/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jantimon%2Fhtml-webpack-plugin/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jantimon%2Fhtml-webpack-plugin/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/jantimon","download_url":"https://codeload.github.com/jantimon/html-webpack-plugin/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":252664614,"owners_count":21784953,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["html-webpack-plugin","webpack"],"created_at":"2024-07-31T07:01:03.745Z","updated_at":"2025-05-13T11:06:37.587Z","avatar_url":"https://github.com/jantimon.png","language":"JavaScript","funding_links":["https://opencollective.com/html-webpack-plugin","https://opencollective.com/html-webpack-plugin/backer/0/website?requireActive=false","https://opencollective.com/html-webpack-plugin/backer/1/website?requireActive=false","https://opencollective.com/html-webpack-plugin/backer/2/website?requireActive=false","https://opencollective.com/html-webpack-plugin/backer/3/website?requireActive=false","https://opencollective.com/html-webpack-plugin/backer/4/website?requireActive=false","https://opencollective.com/html-webpack-plugin/backer/5/website?requireActive=false","https://opencollective.com/html-webpack-plugin/backer/6/website?requireActive=false","https://opencollective.com/html-webpack-plugin/backer/7/website?requireActive=false","https://opencollective.com/html-webpack-plugin/backer/8/website?requireActive=false","https://opencollective.com/html-webpack-plugin/backer/9/website?requireActive=false"],"categories":["JavaScript","Plugins","[Javascript](https://developer.mozilla.org/en-US/docs/Web/JavaScript?retiredLocale=it)","webpack","Options"],"sub_categories":["Rspack Plugins","options.weakRuntimeCheck"],"readme":"[![npm][npm]][npm-url]\n[![node][node]][node-url]\n![npm](https://img.shields.io/npm/dw/html-webpack-plugin.svg)\n[![tests][tests]][tests-url]\n[![Backers on Open Collective](https://opencollective.com/html-webpack-plugin/backers/badge.svg)](#backers)\n[![Sponsors on Open Collective](https://opencollective.com/html-webpack-plugin/sponsors/badge.svg)](#sponsors)\n\n\u003cdiv align=\"center\"\u003e\n  \u003cimg width=\"200\" height=\"200\" src=\"https://www.w3.org/html/logo/downloads/HTML5_Badge.svg\"\u003e\n  \u003ca href=\"https://github.com/webpack/webpack\"\u003e\n    \u003cimg width=\"200\" height=\"200\"\n      src=\"https://webpack.js.org/assets/icon-square-big.svg\"\u003e\n  \u003c/a\u003e\n  \u003cdiv\u003e\n    \u003cimg width=\"100\" height=\"100\" title=\"Webpack Plugin\" src=\"http://michael-ciniawsky.github.io/postcss-load-plugins/logo.svg\"\u003e\n  \u003c/div\u003e\n  \u003ch1\u003eHTML Webpack Plugin\u003c/h1\u003e\n  \u003cp\u003ePlugin that simplifies creation of HTML files to serve your bundles\u003c/p\u003e\n\u003c/div\u003e\n\n\u003ch2 align=\"center\"\u003eInstall\u003c/h2\u003e\n\n\u003ch3\u003eWebpack 5\u003c/h3\u003e\n\n```bash\n  npm i --save-dev html-webpack-plugin\n```\n\n```bash\n  yarn add --dev html-webpack-plugin\n```\n\n\u003ch3\u003eWebpack 4\u003c/h3\u003e\n\n```bash\n  npm i --save-dev html-webpack-plugin@4\n```\n\n```bash\n  yarn add --dev html-webpack-plugin@4\n```\n\nThis is a [webpack](http://webpack.js.org/) plugin that simplifies creation of HTML files to serve your `webpack` bundles. This is especially useful for `webpack` bundles that include a hash in the filename which changes every compilation. You can either let the plugin generate an HTML file for you, supply\nyour own template using `lodash` templates or use your own loader.\n\n\u003ch2 align=\"center\"\u003eSponsors\u003c/h2\u003e\n\n\u003ca href=\"https://opencollective.com/html-webpack-plugin/sponsor/0/website\" target=\"_blank\"\u003e\u003cimg src=\"https://opencollective.com/html-webpack-plugin/sponsor/0/avatar.svg\"\u003e\u003c/a\u003e\n\u003ca href=\"https://opencollective.com/html-webpack-plugin/sponsor/1/website\" target=\"_blank\"\u003e\u003cimg src=\"https://opencollective.com/html-webpack-plugin/sponsor/1/avatar.svg\"\u003e\u003c/a\u003e\n\u003ca href=\"https://opencollective.com/html-webpack-plugin/sponsor/2/website\" target=\"_blank\"\u003e\u003cimg src=\"https://opencollective.com/html-webpack-plugin/sponsor/2/avatar.svg\"\u003e\u003c/a\u003e\n\u003ca href=\"https://opencollective.com/html-webpack-plugin/sponsor/3/website\" target=\"_blank\"\u003e\u003cimg src=\"https://opencollective.com/html-webpack-plugin/sponsor/3/avatar.svg\"\u003e\u003c/a\u003e\n\u003ca href=\"https://opencollective.com/html-webpack-plugin/sponsor/4/website\" target=\"_blank\"\u003e\u003cimg src=\"https://opencollective.com/html-webpack-plugin/sponsor/4/avatar.svg\"\u003e\u003c/a\u003e\n\u003ca href=\"https://opencollective.com/html-webpack-plugin/sponsor/5/website\" target=\"_blank\"\u003e\u003cimg src=\"https://opencollective.com/html-webpack-plugin/sponsor/5/avatar.svg\"\u003e\u003c/a\u003e\n\u003ca href=\"https://opencollective.com/html-webpack-plugin/sponsor/6/website\" target=\"_blank\"\u003e\u003cimg src=\"https://opencollective.com/html-webpack-plugin/sponsor/6/avatar.svg\"\u003e\u003c/a\u003e\n\u003ca href=\"https://opencollective.com/html-webpack-plugin/sponsor/7/website\" target=\"_blank\"\u003e\u003cimg src=\"https://opencollective.com/html-webpack-plugin/sponsor/7/avatar.svg\"\u003e\u003c/a\u003e\n\u003ca href=\"https://opencollective.com/html-webpack-plugin/sponsor/8/website\" target=\"_blank\"\u003e\u003cimg src=\"https://opencollective.com/html-webpack-plugin/sponsor/8/avatar.svg\"\u003e\u003c/a\u003e\n\u003ca href=\"https://opencollective.com/html-webpack-plugin/sponsor/9/website\" target=\"_blank\"\u003e\u003cimg src=\"https://opencollective.com/html-webpack-plugin/sponsor/9/avatar.svg\"\u003e\u003c/a\u003e\n\nThanks for supporting the ongoing improvements to the html-webpack-plugin!\n\n\u003ch2 align=\"center\"\u003eZero Config\u003c/h2\u003e\n\nThe `html-webpack-plugin` works without configuration.  \nIt's a great addition to the [⚙️ webpack-config-plugins](https://github.com/namics/webpack-config-plugins/blob/master/README.md#zero-config-webpack-dev-server-example).\n\n\u003ch2 align=\"center\"\u003ePlugins\u003c/h2\u003e\n\nThe `html-webpack-plugin` provides [hooks](https://github.com/jantimon/html-webpack-plugin#events) to extend it to your needs. There are already some really powerful plugins which can be integrated with zero configuration\n\n- [webpack-subresource-integrity](https://www.npmjs.com/package/webpack-subresource-integrity) for enhanced asset security\n- [appcache-webpack-plugin](https://github.com/lettertwo/appcache-webpack-plugin) for iOS and Android offline usage\n- [favicons-webpack-plugin](https://github.com/jantimon/favicons-webpack-plugin) which generates favicons and icons for iOS, Android and desktop browsers\n- [html-webpack-harddisk-plugin](https://github.com/jantimon/html-webpack-harddisk-plugin) can be used to always write to disk the html file, useful when webpack-dev-server / HMR are being used\n- [html-webpack-inline-svg-plugin](https://github.com/thegc/html-webpack-inline-svg-plugin) to inline SVGs in the resulting HTML file.\n- [html-webpack-exclude-assets-plugin](https://github.com/jamesjieye/html-webpack-exclude-assets-plugin) for excluding assets using regular expressions\n- [html-webpack-include-assets-plugin](https://github.com/jharris4/html-webpack-include-assets-plugin) for including lists of js or css file paths (such as those copied by the copy-webpack-plugin).\n- [html-webpack-injector](https://github.com/thearchitgarg/html-webpack-injector) to inject chunks in `head` or `body` (different locations ) of same html document.\n- [resource-hints-webpack-plugin](https://github.com/jantimon/resource-hints-webpack-plugin) to add resource hints for faster initial page loads using `\u003clink rel='preload'\u003e` and `\u003clink rel='prefetch'\u003e`\n- [link-media-html-webpack-plugin](https://github.com/yaycmyk/link-media-html-webpack-plugin) allows for injected stylesheet `\u003clink /\u003e` tags to have their media attribute set automatically; useful for providing specific desktop/mobile/print etc. stylesheets that the browser will conditionally download\n- [html-webpack-inline-style-plugin](https://github.com/djaax/html-webpack-inline-style-plugin) for inlining styles to HTML elements using [juice](https://github.com/Automattic/juice). Useful for email generation automatisation.\n- [html-webpack-exclude-empty-assets-plugin](https://github.com/KnisterPeter/html-webpack-exclude-empty-assets-plugin) removes empty assets from being added to the html. This fixes some problems with extract-text-plugin with webpack 4.\n- [webpack-concat-plugin](https://github.com/hxlniada/webpack-concat-plugin) for concat and uglify files that needn't to be webpack bundles(for legacy files) and inject to html-webpack-plugin.\n- [html-webpack-link-type-plugin](https://github.com/steadyapp/html-webpack-link-type-plugin) adds a configurable mimetype to resources injected as links (such as adding type=\"text/css\" to external stylesheets) for compatibility with \"strict mode\".\n- [csp-html-webpack-plugin](https://github.com/slackhq/csp-html-webpack-plugin) to add [Content Security Policy](https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Content-Security-Policy) meta tags to the HTML output\n- [strict-csp-html-webpack-plugin](https://github.com/google/strict-csp/tree/main/strict-csp-html-webpack-plugin) to add a [**strict** Content-Security-Policy (CSP)](https://web.dev) as a `meta` tag to the HTML output. A strict CSP is specifically efficient against XSS attacks.\n- [webpack-nomodule-plugin](https://github.com/swimmadude66/webpack-nomodule-plugin) allows you to add a `nomodule` attribute to specific injected scripts, which prevents the scripts from being loaded by newer browsers. Good for limiting loads of polyfills.\n- [html-webpack-skip-assets-plugin](https://github.com/swimmadude66/html-webpack-skip-assets-plugin) Skip adding certain output files to the html file. Built as a drop-in replacement for [html-webpack-exclude-assets-plugin](https://www.npmjs.com/package/html-webpack-exclude-assets-plugin) and works with newer [html-webpack-plugin](https://github.com/jantimon/html-webpack-plugin) versions\n- [html-webpack-inject-preload](https://github.com/principalstudio/html-webpack-inject-preload) allows to add preload links \u0026lt;link rel='preload'\u003e anywhere you want.\n- [inject-body-webpack-plugin](https://github.com/Jaid/inject-body-webpack-plugin) is a simple method of injecting a custom HTML string into the body.\n- [html-webpack-plugin-django](https://github.com/TommasoAmici/html-webpack-plugin-django) a Webpack plugin to inject Django static tags.\n- [html-webpack-inject-attributes-plugin](https://github.com/dyw934854565/html-webpack-inject-attributes-plugin) add extra attributes to inject assetTags.\n- [js-entry-webpack-plugin](https://github.com/liam61/html-webpack-plugin) creates webpack bundles into your js entry\n\n\u003ch2 align=\"center\"\u003eUsage\u003c/h2\u003e\n\nThe plugin will generate an HTML5 file for you that includes all your `webpack`\nbundles in the head using `script` tags. Just add the plugin to your `webpack`\nconfig as follows:\n\n**webpack.config.js**\n\n```js\nconst HtmlWebpackPlugin = require(\"html-webpack-plugin\");\n\nmodule.exports = {\n  entry: \"index.js\",\n  output: {\n    path: __dirname + \"/dist\",\n    filename: \"index_bundle.js\",\n  },\n  plugins: [new HtmlWebpackPlugin()],\n};\n```\n\nThis will generate a file `dist/index.html` containing the following\n\n```html\n\u003c!doctype html\u003e\n\u003chtml\u003e\n  \u003chead\u003e\n    \u003cmeta charset=\"utf-8\" /\u003e\n    \u003ctitle\u003eWebpack App\u003c/title\u003e\n    \u003cscript defer src=\"index_bundle.js\"\u003e\u003c/script\u003e\n  \u003c/head\u003e\n  \u003cbody\u003e\u003c/body\u003e\n\u003c/html\u003e\n```\n\nIf you have multiple `webpack` entry points, they will all be included with `script` tags in the generated HTML.\n\nIf you have any CSS assets in webpack's output (for example, CSS extracted with the [mini-css-extract-plugin](https://github.com/webpack-contrib/mini-css-extract-plugin))\nthen these will be included with `\u003clink\u003e` tags in the HTML head.\n\nIf you have plugins that make use of it, `html-webpack-plugin` should be ordered first before any of the integrated Plugins.\n\n\u003ch2 align=\"center\"\u003eOptions\u003c/h2\u003e\n\nYou can pass a hash of configuration options to `html-webpack-plugin`.\nAllowed values are as follows:\n\n|           Name           |                         Type                         |                        Default                        | Description                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                |\n| :----------------------: | :--------------------------------------------------: | :---------------------------------------------------: | :----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |\n|       **`title`**        |                      `{String}`                      |                     `Webpack App`                     | The title to use for the generated HTML document                                                                                                                                                                                                                                                                                                                                                                                                                                                                                           |\n|      **`filename`**      |                 `{String\\|Function}`                 |                    `'index.html'`                     | The file to write the HTML to. Defaults to `index.html`. You can specify a subdirectory here too (eg: `assets/admin.html`). The `[name]` placeholder will be replaced with the entry name. Can also be a function e.g. `(entryName) =\u003e entryName + '.html'`.                                                                                                                                                                                                                                                                               |\n|      **`template`**      |                      `{String}`                      |                          ``                           | `webpack` relative or absolute path to the template. By default it will use `src/index.ejs` if it exists. Please see the [docs](https://github.com/jantimon/html-webpack-plugin/blob/master/docs/template-option.md) for details                                                                                                                                                                                                                                                                                                           |\n|  **`templateContent`**   |             `{string\\|Function\\|false}`              |                         false                         | Can be used instead of `template` to provide an inline template - please read the [Writing Your Own Templates](https://github.com/jantimon/html-webpack-plugin#writing-your-own-templates) section                                                                                                                                                                                                                                                                                                                                         |\n| **`templateParameters`** |            `{Boolean\\|Object\\|Function}`             |                        `false`                        | Allows to overwrite the parameters used in the template - see [example](https://github.com/jantimon/html-webpack-plugin/tree/master/examples/template-parameters)                                                                                                                                                                                                                                                                                                                                                                          |\n|       **`inject`**       |                 `{Boolean\\|String}`                  |                        `true`                         | `true \\|\\| 'head' \\|\\| 'body' \\|\\| false` Inject all assets into the given `template` or `templateContent`. When passing `'body'` all javascript resources will be placed at the bottom of the body element. `'head'` will place the scripts in the head element. Passing `true` will add it to the head/body depending on the `scriptLoading` option. Passing `false` will disable automatic injections. - see the [inject:false example](https://github.com/jantimon/html-webpack-plugin/tree/master/examples/custom-insertion-position) |\n|     **`publicPath`**     |                  `{String\\|'auto'}`                  |                       `'auto'`                        | The publicPath used for script and link tags                                                                                                                                                                                                                                                                                                                                                                                                                                                                                               |\n|   **`scriptLoading`**    | `{'blocking'\\|'defer'\\|'module'\\|'systemjs-module'}` |                       `'defer'`                       | Modern browsers support non blocking javascript loading (`'defer'`) to improve the page startup performance. Setting to `'module'` adds attribute [`type=\"module\"`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Guide/Modules#applying_the_module_to_your_html). This also implies \"defer\", since modules are automatically deferred.                                                                                                                                                                                          |\n|      **`favicon`**       |                      `{String}`                      |                          ``                           | Adds the given favicon path to the output HTML                                                                                                                                                                                                                                                                                                                                                                                                                                                                                             |\n|        **`meta`**        |                      `{Object}`                      |                         `{}`                          | Allows to inject `meta`-tags. E.g. `meta: {viewport: 'width=device-width, initial-scale=1, shrink-to-fit=no'}`                                                                                                                                                                                                                                                                                                                                                                                                                             |\n|        **`base`**        |              `{Object\\|String\\|false}`               |                        `false`                        | Inject a [`base`](https://developer.mozilla.org/en-US/docs/Web/HTML/Element/base) tag. E.g. `base: \"https://example.com/path/page.html`                                                                                                                                                                                                                                                                                                                                                                                                    |\n|       **`minify`**       |                 `{Boolean\\|Object}`                  | `true` if `mode` is `'production'`, otherwise `false` | Controls if and in what ways the output should be minified. See [minification](#minification) below for more details.                                                                                                                                                                                                                                                                                                                                                                                                                      |\n|        **`hash`**        |                     `{Boolean}`                      |                        `false`                        | If `true` then append a unique `webpack` compilation hash to all included scripts and CSS files (i.e. `main.js?hash=compilation_hash`). This is useful for cache busting                                                                                                                                                                                                                                                                                                                                                                   |\n|       **`cache`**        |                     `{Boolean}`                      |                        `true`                         | Emit the file only if it was changed                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                       |\n|     **`showErrors`**     |                     `{Boolean}`                      |                        `true`                         | Errors details will be written into the HTML page                                                                                                                                                                                                                                                                                                                                                                                                                                                                                          |\n|       **`chunks`**       |                        `{?}`                         |                          `?`                          | Allows you to add only some chunks (e.g only the unit-test chunk)                                                                                                                                                                                                                                                                                                                                                                                                                                                                          |\n|   **`chunksSortMode`**   |                 `{String\\|Function}`                 |                        `auto`                         | Allows to control how chunks should be sorted before they are included to the HTML. Allowed values are `'none' \\| 'auto' \\| 'manual' \\| {Function}`                                                                                                                                                                                                                                                                                                                                                                                        |\n|   **`excludeChunks`**    |                  `{Array.\u003cstring\u003e}`                  |                          ``                           | Allows you to skip some chunks (e.g don't add the unit-test chunk)                                                                                                                                                                                                                                                                                                                                                                                                                                                                         |\n|       **`xhtml`**        |                     `{Boolean}`                      |                        `false`                        | If `true` render the `link` tags as self-closing (XHTML compliant)                                                                                                                                                                                                                                                                                                                                                                                                                                                                         |\n\nHere's an example webpack config illustrating how to use these options\n\n**webpack.config.js**\n\n```js\n{\n  entry: 'index.js',\n  output: {\n    path: __dirname + '/dist',\n    filename: 'index_bundle.js'\n  },\n  plugins: [\n    new HtmlWebpackPlugin({\n      title: 'My App',\n      filename: 'assets/admin.html'\n    })\n  ]\n}\n```\n\n### Generating Multiple HTML Files\n\nTo generate more than one HTML file, declare the plugin more than\nonce in your plugins array\n\n**webpack.config.js**\n\n```js\n{\n  entry: 'index.js',\n  output: {\n    path: __dirname + '/dist',\n    filename: 'index_bundle.js'\n  },\n  plugins: [\n    new HtmlWebpackPlugin(), // Generates default index.html\n    new HtmlWebpackPlugin({  // Also generate a test.html\n      filename: 'test.html',\n      template: 'src/assets/test.html'\n    })\n  ]\n}\n```\n\n### Writing Your Own Templates\n\nIf the default generated HTML doesn't meet your needs you can supply\nyour own template. The easiest way is to use the `template` option and pass a custom HTML file.\nThe html-webpack-plugin will automatically inject all necessary CSS, JS, manifest\nand favicon files into the markup.\n\nDetails of other template loaders are [documented here](https://github.com/jantimon/html-webpack-plugin/blob/master/docs/template-option.md).\n\n```js\nplugins: [\n  new HtmlWebpackPlugin({\n    title: \"Custom template\",\n    // Load a custom template (lodash by default)\n    template: \"index.html\",\n  }),\n];\n```\n\n**index.html**\n\n```html\n\u003c!doctype html\u003e\n\u003chtml\u003e\n  \u003chead\u003e\n    \u003cmeta charset=\"utf-8\" /\u003e\n    \u003ctitle\u003e\u003c%= htmlWebpackPlugin.options.title %\u003e\u003c/title\u003e\n  \u003c/head\u003e\n  \u003cbody\u003e\u003c/body\u003e\n\u003c/html\u003e\n```\n\nIf you already have a template loader, you can use it to parse the template.\nPlease note that this will also happen if you specify the html-loader and use `.html` file as template.\n\n**webpack.config.js**\n\n```js\nmodule: {\n  loaders: [\n    { test: /\\.hbs$/, loader: \"handlebars-loader\" }\n  ]\n},\nplugins: [\n  new HtmlWebpackPlugin({\n    title: 'Custom template using Handlebars',\n    template: 'index.hbs'\n  })\n]\n```\n\nYou can use the `lodash` syntax out of the box. If the `inject` feature doesn't fit your needs and you want full control over the asset placement use the [default template](https://github.com/jaketrent/html-webpack-template/blob/86f285d5c790a6c15263f5cc50fd666d51f974fd/index.html) of the [html-webpack-template project](https://github.com/jaketrent/html-webpack-template) as a starting point for writing your own.\n\nThe following variables are available in the template by default (you can extend them using the `templateParameters` option):\n\n- `htmlWebpackPlugin`: data specific to this plugin\n\n  - `htmlWebpackPlugin.options`: the options hash that was passed to\n    the plugin. In addition to the options actually used by this plugin,\n    you can use this hash to pass arbitrary data through to your template.\n\n  - `htmlWebpackPlugin.tags`: the prepared `headTags` and `bodyTags` Array to render the `\u003cbase\u003e`, `\u003cmeta\u003e`, `\u003cscript\u003e` and `\u003clink\u003e` tags.\n    Can be used directly in templates and literals. For example:\n    ```html\n    \u003chtml\u003e\n      \u003chead\u003e\n        \u003c%= htmlWebpackPlugin.tags.headTags %\u003e\n      \u003c/head\u003e\n      \u003cbody\u003e\n        \u003c%= htmlWebpackPlugin.tags.bodyTags %\u003e\n      \u003c/body\u003e\n    \u003c/html\u003e\n    ```\n  - `htmlWebpackPlugin.files`: direct access to the files used during the compilation.\n\n    ```typescript\n    publicPath: string;\n    js: string[];\n    css: string[];\n    manifest?: string;\n    favicon?: string;\n    ```\n\n- `webpackConfig`: the webpack configuration that was used for this compilation. This\n  can be used, for example, to get the `publicPath` (`webpackConfig.output.publicPath`).\n\n- `compilation`: the webpack [compilation object](https://webpack.js.org/api/compilation-object/).\n  This can be used, for example, to get the contents of processed assets and inline them\n  directly in the page, through `compilation.assets[...].source()`\n  (see [the inline template example](examples/inline/template.pug)).\n\nThe template can also be directly inlined directly into the options object.  \n⚠️ **`templateContent` does not allow to use webpack loaders for your template and will not watch for template file changes**\n\n**webpack.config.js**\n\n```js\nnew HtmlWebpackPlugin({\n  templateContent: `\n    \u003chtml\u003e\n      \u003cbody\u003e\n        \u003ch1\u003eHello World\u003c/h1\u003e\n      \u003c/body\u003e\n    \u003c/html\u003e\n  `,\n});\n```\n\nThe `templateContent` can also access all `templateParameters` values.  \n⚠️ **`templateContent` does not allow to use webpack loaders for your template and will not watch for template file changes**\n\n**webpack.config.js**\n\n```js\nnew HtmlWebpackPlugin({\n  inject: false,\n  templateContent: ({ htmlWebpackPlugin }) =\u003e `\n    \u003chtml\u003e\n      \u003chead\u003e\n        ${htmlWebpackPlugin.tags.headTags}\n      \u003c/head\u003e\n      \u003cbody\u003e\n        \u003ch1\u003eHello World\u003c/h1\u003e\n        ${htmlWebpackPlugin.tags.bodyTags}\n      \u003c/body\u003e\n    \u003c/html\u003e\n  `,\n});\n```\n\n### Filtering Chunks\n\nTo include only certain chunks you can limit the chunks being used\n\n**webpack.config.js**\n\n```js\nplugins: [\n  new HtmlWebpackPlugin({\n    chunks: [\"app\"],\n  }),\n];\n```\n\nIt is also possible to exclude certain chunks by setting the `excludeChunks` option\n\n**webpack.config.js**\n\n```js\nplugins: [\n  new HtmlWebpackPlugin({\n    excludeChunks: [\"dev-helper\"],\n  }),\n];\n```\n\n### Minification\n\nIf the `minify` option is set to `true` (the default when webpack's `mode` is `'production'`),\nthe generated HTML will be minified using [html-minifier-terser](https://github.com/DanielRuf/html-minifier-terser)\nand the following options:\n\n```js\n{\n  collapseWhitespace: true,\n  keepClosingSlash: true,\n  removeComments: true,\n  removeRedundantAttributes: true,\n  removeScriptTypeAttributes: true,\n  removeStyleLinkTypeAttributes: true,\n  useShortDoctype: true\n}\n```\n\nTo use custom [html-minifier options](https://github.com/DanielRuf/html-minifier-terser#options-quick-reference)\npass an object to `minify` instead. This object will not be merged with the defaults above.\n\nTo disable minification during production mode set the `minify` option to `false`.\n\n### Meta Tags\n\nIf the `meta` option is set the html-webpack-plugin will inject meta tags.  \nFor the default template the html-webpack-plugin will already provide a default for the `viewport` meta tag.\n\nPlease take a look at this well maintained list of almost all [possible meta tags](https://github.com/joshbuchea/HEAD#meta).\n\n#### name/content meta tags\n\nMost meta tags are configured by setting a `name` and a `content` attribute.  \nTo add those use a key/value pair:\n\n**webpack.config.js**\n\n```js\nplugins: [\n  new HtmlWebpackPlugin({\n    meta: {\n      viewport: \"width=device-width, initial-scale=1, shrink-to-fit=no\",\n      // Will generate: \u003cmeta name=\"viewport\" content=\"width=device-width, initial-scale=1, shrink-to-fit=no\"\u003e\n      \"theme-color\": \"#4285f4\",\n      // Will generate: \u003cmeta name=\"theme-color\" content=\"#4285f4\"\u003e\n    },\n  }),\n];\n```\n\n#### Simulate http response headers\n\nThe **http-equiv** attribute is essentially used to simulate a HTTP response header.  \nThis format is supported using an object notation which allows you to add any attribute:\n\n**webpack.config.js**\n\n```js\nplugins: [\n  new HtmlWebpackPlugin({\n    meta: {\n      \"Content-Security-Policy\": {\n        \"http-equiv\": \"Content-Security-Policy\",\n        content: \"default-src https:\",\n      },\n      // Will generate: \u003cmeta http-equiv=\"Content-Security-Policy\" content=\"default-src https:\"\u003e\n      // Which equals to the following http header: `Content-Security-Policy: default-src https:`\n      \"set-cookie\": {\n        \"http-equiv\": \"set-cookie\",\n        content: \"name=value; expires=date; path=url\",\n      },\n      // Will generate: \u003cmeta http-equiv=\"set-cookie\" content=\"value; expires=date; path=url\"\u003e\n      // Which equals to the following http header: `set-cookie: value; expires=date; path=url`\n    },\n  }),\n];\n```\n\n### Base Tag\n\nWhen the `base` option is used,\nhtml-webpack-plugin will inject a [base tag](https://developer.mozilla.org/en-US/docs/Web/HTML/Element/base).\nBy default, a base tag will not be injected.\n\nThe following two are identical and will both insert `\u003cbase href=\"http://example.com/some/page.html\"\u003e`:\n\n```js\nnew HtmlWebpackPlugin({\n  base: \"http://example.com/some/page.html\",\n});\n```\n\n```js\nnew HtmlWebpackPlugin({\n  base: { href: \"http://example.com/some/page.html\" },\n});\n```\n\nThe `target` can be specified with the corresponding key:\n\n```js\nnew HtmlWebpackPlugin({\n  base: {\n    href: \"http://example.com/some/page.html\",\n    target: \"_blank\",\n  },\n});\n```\n\nwhich will inject the element `\u003cbase href=\"http://example.com/some/page.html\" target=\"_blank\"\u003e`.\n\n### Long Term Caching\n\nFor long term caching add `contenthash` to the filename.\n\n**Example:**\n\n```js\nplugins: [\n  new HtmlWebpackPlugin({\n    filename: \"index.[contenthash].html\",\n  }),\n];\n```\n\n`contenthash` is the hash of the content of the output file.\n\nRefer webpack's [Template Strings](https://webpack.js.org/configuration/output/#template-strings) for more details\n\n### Events\n\nTo allow other [plugins](https://github.com/webpack/docs/wiki/plugins) to alter the HTML this plugin executes\n[tapable](https://github.com/webpack/tapable/tree/master) hooks.\n\nThe [lib/hooks.js](https://github.com/jantimon/html-webpack-plugin/blob/master/lib/hooks.js) contains all information\nabout which values are passed.\n\n[![Concept flow uml](https://raw.githubusercontent.com/jantimon/html-webpack-plugin/master/flow.png)](https://github.com/jantimon/html-webpack-plugin/blob/master/flow.puml)\n\n#### `beforeAssetTagGeneration` hook\n\n```\n    AsyncSeriesWaterfallHook\u003c{\n      assets: {\n        publicPath: string,\n        js: Array\u003c{string}\u003e,\n        css: Array\u003c{string}\u003e,\n        favicon?: string | undefined,\n        manifest?: string | undefined\n      },\n      outputName: string,\n      plugin: HtmlWebpackPlugin\n    }\u003e\n```\n\n#### `alterAssetTags` hook\n\n```\n    AsyncSeriesWaterfallHook\u003c{\n      assetTags: {\n        scripts: Array\u003cHtmlTagObject\u003e,\n        styles: Array\u003cHtmlTagObject\u003e,\n        meta: Array\u003cHtmlTagObject\u003e,\n      },\n      publicPath: string,\n      outputName: string,\n      plugin: HtmlWebpackPlugin\n    }\u003e\n```\n\n#### `alterAssetTagGroups` hook\n\n```\n    AsyncSeriesWaterfallHook\u003c{\n      headTags: Array\u003cHtmlTagObject | HtmlTagObject\u003e,\n      bodyTags: Array\u003cHtmlTagObject | HtmlTagObject\u003e,\n      publicPath: string,\n      outputName: string,\n      plugin: HtmlWebpackPlugin\n    }\u003e\n```\n\n#### `afterTemplateExecution` hook\n\n```\n    AsyncSeriesWaterfallHook\u003c{\n      html: string,\n      headTags: Array\u003cHtmlTagObject | HtmlTagObject\u003e,\n      bodyTags: Array\u003cHtmlTagObject | HtmlTagObject\u003e,\n      outputName: string,\n      plugin: HtmlWebpackPlugin,\n    }\u003e\n```\n\n#### `beforeEmit` hook\n\n```\n    AsyncSeriesWaterfallHook\u003c{\n      html: string,\n      outputName: string,\n      plugin: HtmlWebpackPlugin,\n    }\u003e\n```\n\n#### `afterEmit` hook\n\n```\n    AsyncSeriesWaterfallHook\u003c{\n      outputName: string,\n      plugin: HtmlWebpackPlugin\n    }\u003e\n```\n\nExample implementation: [webpack-subresource-integrity](https://www.npmjs.com/package/webpack-subresource-integrity)\n\n**plugin.js**\n\n```js\n// If your plugin is direct dependent to the html webpack plugin:\nconst HtmlWebpackPlugin = require(\"html-webpack-plugin\");\n// If your plugin is using html-webpack-plugin as an optional dependency\n// you can use https://github.com/tallesl/node-safe-require instead:\nconst HtmlWebpackPlugin = require(\"safe-require\")(\"html-webpack-plugin\");\n\nclass MyPlugin {\n  apply(compiler) {\n    compiler.hooks.compilation.tap(\"MyPlugin\", (compilation) =\u003e {\n      console.log(\"The compiler is starting a new compilation...\");\n\n      // Static Plugin interface |compilation |HOOK NAME | register listener\n      HtmlWebpackPlugin.getCompilationHooks(compilation).beforeEmit.tapAsync(\n        \"MyPlugin\", // \u003c-- Set a meaningful name here for stacktraces\n        (data, cb) =\u003e {\n          // Manipulate the content\n          data.html += \"The Magic Footer\";\n          // Tell webpack to move on\n          cb(null, data);\n        },\n      );\n    });\n  }\n}\n\nmodule.exports = MyPlugin;\n```\n\n**webpack.config.js**\n\n```js\nplugins: [new MyPlugin({ options: \"\" })];\n```\n\nNote that the callback must be passed the HtmlWebpackPluginData in order to pass this onto any other plugins listening on the same `beforeEmit` event\n\n\u003ch2 align=\"center\"\u003eMaintainers\u003c/h2\u003e\n\n\u003ctable\u003e\n  \u003ctbody\u003e\n    \u003ctr\u003e\n      \u003ctd align=\"center\"\u003e\n        \u003cimg width=\"150\" height=\"150\"\n        src=\"https://avatars3.githubusercontent.com/u/4113649?v=3\u0026s=150\"\u003e\n        \u003c/br\u003e\n        \u003ca href=\"https://github.com/jantimon\"\u003eJan Nicklas\u003c/a\u003e\n      \u003c/td\u003e\n      \u003ctd align=\"center\"\u003e\n        \u003cimg width=\"150\" height=\"150\"\n        src=\"https://avatars2.githubusercontent.com/u/4112409?v=3\u0026s=150\"\u003e\n        \u003c/br\u003e\n        \u003ca href=\"https://github.com/mastilver\"\u003eThomas Sileghem\u003c/a\u003e\n      \u003c/td\u003e\n    \u003c/tr\u003e\n  \u003ctbody\u003e\n\u003c/table\u003e\n\n## Backers\n\nThank you to all our backers!  \nIf you want to support the project as well [become a sponsor](https://opencollective.com/html-webpack-plugin#sponsor) or a [a backer](https://opencollective.com/html-webpack-plugin#backer).\n\n\u003ca href=\"https://opencollective.com/html-webpack-plugin/backer/0/website?requireActive=false\" target=\"_blank\"\u003e\u003cimg src=\"https://opencollective.com/html-webpack-plugin/backer/0/avatar.svg?requireActive=false\"\u003e\u003c/a\u003e\n\u003ca href=\"https://opencollective.com/html-webpack-plugin/backer/1/website?requireActive=false\" target=\"_blank\"\u003e\u003cimg src=\"https://opencollective.com/html-webpack-plugin/backer/1/avatar.svg?requireActive=false\"\u003e\u003c/a\u003e\n\u003ca href=\"https://opencollective.com/html-webpack-plugin/backer/2/website?requireActive=false\" target=\"_blank\"\u003e\u003cimg src=\"https://opencollective.com/html-webpack-plugin/backer/2/avatar.svg?requireActive=false\"\u003e\u003c/a\u003e\n\u003ca href=\"https://opencollective.com/html-webpack-plugin/backer/3/website?requireActive=false\" target=\"_blank\"\u003e\u003cimg src=\"https://opencollective.com/html-webpack-plugin/backer/3/avatar.svg?requireActive=false\"\u003e\u003c/a\u003e\n\u003ca href=\"https://opencollective.com/html-webpack-plugin/backer/4/website?requireActive=false\" target=\"_blank\"\u003e\u003cimg src=\"https://opencollective.com/html-webpack-plugin/backer/4/avatar.svg?requireActive=false\"\u003e\u003c/a\u003e\n\u003ca href=\"https://opencollective.com/html-webpack-plugin/backer/5/website?requireActive=false\" target=\"_blank\"\u003e\u003cimg src=\"https://opencollective.com/html-webpack-plugin/backer/5/avatar.svg?requireActive=false\"\u003e\u003c/a\u003e\n\u003ca href=\"https://opencollective.com/html-webpack-plugin/backer/6/website?requireActive=false\" target=\"_blank\"\u003e\u003cimg src=\"https://opencollective.com/html-webpack-plugin/backer/6/avatar.svg?requireActive=false\"\u003e\u003c/a\u003e\n\u003ca href=\"https://opencollective.com/html-webpack-plugin/backer/7/website?requireActive=false\" target=\"_blank\"\u003e\u003cimg src=\"https://opencollective.com/html-webpack-plugin/backer/7/avatar.svg?requireActive=false\"\u003e\u003c/a\u003e\n\u003ca href=\"https://opencollective.com/html-webpack-plugin/backer/8/website?requireActive=false\" target=\"_blank\"\u003e\u003cimg src=\"https://opencollective.com/html-webpack-plugin/backer/8/avatar.svg?requireActive=false\"\u003e\u003c/a\u003e\n\u003ca href=\"https://opencollective.com/html-webpack-plugin/backer/9/website?requireActive=false\" target=\"_blank\"\u003e\u003cimg src=\"https://opencollective.com/html-webpack-plugin/backer/9/avatar.svg?requireActive=false\"\u003e\u003c/a\u003e\n\n## Contributors\n\nThis project exists thanks to all the people who contribute.\n\nYou're free to contribute to this project by submitting [issues](https://github.com/jantimon/html-webpack-plugin/issues) and/or [pull requests](https://github.com/jantimon/html-webpack-plugin/pulls). This project is test-driven, so keep in mind that every change and new feature should be covered by tests.\n\n\u003ca href=\"https://github.com/jantimon/html-webpack-plugin/graphs/contributors\"\u003e\u003cimg src=\"https://opencollective.com/html-webpack-plugin/contributors.svg?width=890\u0026button=false\" /\u003e\u003c/a\u003e\n\n[npm]: https://img.shields.io/npm/v/html-webpack-plugin.svg\n[npm-url]: https://npmjs.com/package/html-webpack-plugin\n[node]: https://img.shields.io/node/v/html-webpack-plugin.svg\n[node-url]: https://nodejs.org\n[tests]: https://github.com/jantimon/html-webpack-plugin/workflows/CI/badge.svg\n[tests-url]: https://github.com/jantimon/html-webpack-plugin/actions?query=workflow%3ACI\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjantimon%2Fhtml-webpack-plugin","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fjantimon%2Fhtml-webpack-plugin","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjantimon%2Fhtml-webpack-plugin/lists"}