html-plugin

Create HTML files to serve your webpack bundles


Keywords
webpack, plugin, html, webpack-plugin
License
Unlicense
Install
npm install html-plugin@0.1.0

Documentation

HTML Plugin

Here is the plugin mentioned in the offcial webpack guide.

build status coverage npm dependencies

This plugin aims to create index.html for PWAs, with good default template built-in, and let you customize with simple configuration.

You can also provide your own templates in the same way you compose apps - JSX and React components.

Installation

Install the plugin with npm:

$ npm i -D html-plugin vhtml

Usage

Add the plugin to webpack config:

+ const HtmlPlugin = require('html-plugin')
  module.exports = {
    entry: 'index.js',
    output: {
      path: __dirname + '/dist',
      filename: 'bundle.js'
    },
+   plugins: [
+     new HtmlPlugin({
+       title: 'My App'
+     })
+   ]
  }

This will generate dist/index.html:

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

<head>
  <title>My App</title>
  <meta charset="utf-8" />
  <meta name="mobile-web-app-capable" content="yes" />
  <meta name="viewport" content="width=device-width, initial-scale=1.0" />
  <meta name="theme-color" content="#000" />
  <meta name="apple-mobile-web-app-capable" content="yes" />
  <meta name="apple-mobile-web-app-status-bar-style" content="black" />
  <link rel="manifest" href="/manifest.json" />
  <link rel="shortcut icon" href="/favicon.png" />
</head>

<body>
  <div id="root"></div>
  <script src="bundle.js"></script>
</body>

</html>

Options

  • filename
  • title / name
  • lang
  • themeColor
  • manifest
  • favicon