Important: This documentation covers Yarn 1 (Classic).
For Yarn 2+ docs and migration guide, see yarnpkg.com.

Package detail

html-webpack-harddisk-plugin

jantimon230.9kMIT2.0.0TypeScript support: included

Write html files to hard disk even when using the webpack dev server or middleware

webpack, plugin, html-webpack-plugin, disk, template

readme

Harddisk extension for the HTML Webpack Plugin

npm version Dependency Status Build Status js-semistandard-style

Enhances html-webpack-plugin functionality by adding the {alwaysWriteToDisk: true|false} option.

This is an extension plugin for the webpack plugin html-webpack-plugin - a plugin that simplifies the creation of HTML files to serve your webpack bundles.

Installation

You must be running webpack on node 10.x or higher

Install the plugin with npm:

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

Basic Usage

Require the plugin in your webpack config:

const HtmlWebpackHarddiskPlugin = require('html-webpack-harddisk-plugin');

Add the plugin to your webpack config as follows:

plugins: [
  new HtmlWebpackPlugin(),
  new HtmlWebpackHarddiskPlugin()
]  

The above configuration will actually do nothing due to the configuration defaults.

As soon as you now set alwaysWriteToDisk to true the generated output of the HtmlWebpackPlugin will always be written to disk. This is very useful if you want to pick up the output with another middleware.

plugins: [
  new HtmlWebpackPlugin({
        alwaysWriteToDisk: true
    }),
  new HtmlWebpackHarddiskPlugin()
]  

Even if you generate multiple files make sure that you add the HtmlWebpackHarddiskPlugin only once:

plugins: [
  new HtmlWebpackPlugin({
        alwaysWriteToDisk: true
    }),
  new HtmlWebpackPlugin({
        alwaysWriteToDisk: true,
        filename: 'demo.html'
    }),
  new HtmlWebpackPlugin({
        alwaysWriteToDisk: false,
        filename: 'test.html'
    }),
  new HtmlWebpackHarddiskPlugin()
]  

If you need to set the output path explicitly (for example when using with webpack-dev-server middleware) then pass in the outputPath option:

new HtmlWebpackHarddiskPlugin({
  outputPath: path.resolve(__dirname, 'views')
})

changelog

Changelog

All notable changes to this project will be documented in this file. See standard-version for commit guidelines.

2.0.0 (2021-02-15)

⚠ BREAKING CHANGES

  • drop support for node < 10.16 and webpack 1-3

Features

  • add support for webpack 5 (03dd746)

1.0.2 (2020-06-16)

1.0.1 (2018-10-19)

Features

  • Publish index.d.ts to npm

1.0.0 (2018-10-15)

Bug Fixes

Features

  • Add support for html-webpack-plugin 4 (a7379f1)

BREAKING CHANGES

  • Drop support for node < 6