MCPcopy Index your code
hub / github.com/jantimon/html-webpack-plugin

github.com/jantimon/html-webpack-plugin @v5.6.7

repository ↗ · DeepWiki ↗ · release v5.6.7 ↗ · Ask this repo → · + Follow
76 symbols 141 edges 63 files 46 documented · 61% 139 cross-repo links updated 16d ago2.29.0 · 2017-07-26★ 10,73131 open issues
README

[![npm][npm]][npm-url] [![node][node]][node-url] npm [![tests][tests]][tests-url] Backers on Open Collective Sponsors on Open Collective

<img width="100" height="100" title="Webpack Plugin" src="http://michael-ciniawsky.github.io/postcss-load-plugins/logo.svg">

HTML Webpack Plugin

Plugin that simplifies creation of HTML files to serve your bundles

Install

Webpack 5

  npm i --save-dev html-webpack-plugin
  yarn add --dev html-webpack-plugin

Webpack 4

  npm i --save-dev html-webpack-plugin@4
  yarn add --dev html-webpack-plugin@4

This is a webpack 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 your own template using lodash templates or use your own loader.

Sponsors

Thanks for supporting the ongoing improvements to the html-webpack-plugin!

Zero Config

The html-webpack-plugin works without configuration.
It's a great addition to the ⚙️ webpack-config-plugins.

Plugins

The html-webpack-plugin provides hooks to extend it to your needs. There are already some really powerful plugins which can be integrated with zero configuration

Usage

The plugin will generate an HTML5 file for you that includes all your webpack bundles in the head using script tags. Just add the plugin to your webpack config as follows:

webpack.config.js

const HtmlWebpackPlugin = require("html-webpack-plugin");

module.exports = {
  entry: "index.js",
  output: {
    path: __dirname + "/dist",
    filename: "index_bundle.js",
  },
  plugins: [new HtmlWebpackPlugin()],
};

This will generate a file dist/index.html containing the following

<!doctype html>
<html>
  <head>
    <meta charset="utf-8" />
    <title>Webpack App</title>
    <script defer src="https://github.com/jantimon/html-webpack-plugin/raw/v5.6.7/index_bundle.js"></script>
  </head>
  <body></body>
</html>

If you have multiple webpack entry points, they will all be included with script tags in the generated HTML.

If you have any CSS assets in webpack's output (for example, CSS extracted with the mini-css-extract-plugin) then these will be included with <link> tags in the HTML head.

If you have plugins that make use of it, html-webpack-plugin should be ordered first before any of the integrated Plugins.

Options

You can pass a hash of configuration options to html-webpack-plugin. Allowed values are as follows:

Name Type Default Description
title {String} Webpack App The title to use for the generated HTML document
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) => entryName + '.html'.
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 for details
templateContent {string\|Function\|false} false Can be used instead of template to provide an inline template - please read the Writing Your Own Templates section
templateParameters {Boolean\|Object\|Function} false Allows to overwrite the parameters used in the template - see [example](ht

Extension points exported contracts — how you extend this code

ProcessedOptions (Interface)
* The plugin options after adding default values
typings.d.ts
TemplateParameter (Interface)
* The values which are available during template execution * * Please keep in mind that the `templateParameter` op
typings.d.ts
HtmlTagObject (Interface)
* A tag element according to the htmlWebpackPlugin object notation
typings.d.ts
Options (Interface)
(no doc)
typings.d.ts
Hooks (Interface)
(no doc)
typings.d.ts

Core symbols most depended-on inside this repo

getCompilationHooks
called by 29
index.js
toString
called by 6
lib/html-tags.js
appendHash
called by 3
index.js
apply
called by 3
lib/cached-child-compiler.js
htmlTagObjectToString
called by 3
lib/html-tags.js
evaluateCompilationResult
called by 2
index.js
prepareAssetTagGroupForRendering
called by 2
index.js
getTemplatePath
called by 1
index.js

Shape

Method 44
Class 14
Function 13
Interface 5

Languages

TypeScript100%

Modules by API surface

index.js28 symbols
lib/cached-child-compiler.js17 symbols
typings.d.ts7 symbols
lib/child-compiler.js6 symbols
spec/caching.spec.js5 symbols
lib/html-tags.js5 symbols
spec/hot.spec.js3 symbols
spec/basic.spec.js3 symbols
spec/example.spec.js1 symbols
lib/errors.js1 symbols

Dependencies from manifests, versioned

@commitlint/cli18.4.4 · 1×
@commitlint/config-conventional18.4.4 · 1×
@types/html-minifier-terser6.0.0 · 1×
@types/node20.2.5 · 1×
cross-env7.0.3 · 1×
cspell8.3.2 · 1×
css-loader5.0.1 · 1×
cz-conventional-changelog2.1.0 · 1×
dir-compare3.3.0 · 1×
eslint8.56.0 · 1×
handlebars-loader1.7.3 · 1×
html-loader2.1.1 · 1×

For agents

$ claude mcp add html-webpack-plugin \
  -- python -m otcore.mcp_server <graph>

⬇ download graph artifact