Go to file
Charles Blaxland ef96f87a20 Update readme 2014-08-13 10:23:00 +10:00
spec Add support for specifying the title of the generated HTML 2014-08-13 09:30:27 +10:00
.gitignore Generate a default index.html from a single webpack entry point 2014-08-12 13:01:56 +10:00
LICENSE Initial commit 2014-08-08 13:19:15 +10:00
README.md Update readme 2014-08-13 10:23:00 +10:00
default_index.html Add support for specifying the title of the generated HTML 2014-08-13 09:30:27 +10:00
index.js Add support for specifying the title of the generated HTML 2014-08-13 09:30:27 +10:00
package.json Bump version to 0.1.0 2014-08-12 23:02:04 +10:00

README.md

HTML Webpack Plugin

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 or supply your own template (using blueimp templates).

Installation

Install the plugin with npm:

$ npm install html-webpack-plugin --save-dev

Basic Usage

The plugin will generate an HTML5 file for you that includes all your webpack bundles in the body.

For example, this webpack config...

var HtmlWebpackPlugin = require('html-webpack-plugin')
var webpackConfig = {
  entry: 'index.js',
  output: {
    path: 'dist',
    filename: 'index_bundle.js'
  },
  plugins: [new HtmlWebpackPlugin()]
}

generates a file dist/index.html containing the following:

<!DOCTYPE html>
<html>
  <head>
    <meta http-equiv="Content-type" content="text/html; charset=utf-8"/>
    <title>Webpack App</title>
  </head>
  <body>
    <script src="index_bundle.js"></script>
  </body>
</html>

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

Configuration

You can pass a hash of configuration options to HtmlWebpackPlugin. Allowed values are as follows:

  • title: The title to use for the generated HTML document.

Here's an example webpack config illustrating how to use these options:

{
  entry: 'index.js',
  output: {
    path: 'dist',
    filename: 'index_bundle.js'
  },
  plugins: [
    new HtmlWebpackPlugin({
      title: 'My App'
    })
  ]
}

Writing Your Own Templates

TODO