Registry / devops / html-webpack-harddisk-plugin

html-webpack-harddisk-plugin

JSON →
library2.0.0jsnpmunverified

The `html-webpack-harddisk-plugin` is an extension for `html-webpack-plugin`, specifically designed to ensure that generated HTML files are written to the hard disk, even when using Webpack's development server or middleware. While `html-webpack-plugin` typically serves assets from memory in development, this plugin forces physical file creation. Currently at version 2.0.0, it maintains a stable release cadence, often aligning with major updates to its peer dependencies, `html-webpack-plugin` (v5+) and `webpack` (v5+). Its primary differentiator is its focused utility in scenarios where external tools or services require access to the actual HTML files on disk during the development workflow, such as for server-side rendering setups or specific build integrations, rather than just in-memory representations.

npm install html-webpack-harddisk-plugin
INSTALL
IMPORT
SIG · HTML-WEBPACK-HARDD
H
html-webpack-harddisk-plugin
devopsjavascriptv2.0.0
Install
Import
Disk
Pass rate
0/ 6
Env Coverage0 / 6
glibc
1822
musl
1822
Install & Compatibility
Where this runs
tested against v? · npm install
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
musl
node 18226 runs
build_error
glibc
node 18226 runs
build_error
Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

HtmlWebpackHarddiskPlugin
const HtmlWebpackHarddiskPlugin = require('html-webpack-harddisk-plugin');
import HtmlWebpackHarddiskPlugin from 'html-webpack-harddisk-plugin';
CommonJS `require` is shown in the official docs, suitable for webpack config files.
HtmlWebpackHarddiskPlugin
import HtmlWebpackHarddiskPlugin from 'html-webpack-harddisk-plugin';
const HtmlWebpackHarddiskPlugin = require('html-webpack-harddisk-plugin');
ES Modules `import` is also supported, especially if your webpack config uses ESM or for type imports.
Options
import type { Options } from 'html-webpack-harddisk-plugin';
For TypeScript users, import the `Options` type to define plugin configuration.

This configuration demonstrates how to integrate the plugin with two instances of `html-webpack-plugin`, forcing both 'index.html' and 'another.html' to be written to disk during development.

const path = require('path'); const HtmlWebpackPlugin = require('html-webpack-plugin'); const HtmlWebpackHarddiskPlugin = require('html-webpack-harddisk-plugin'); module.exports = { mode: 'development', entry: './src/index.js', output: { path: path.resolve(__dirname, 'dist'), filename: 'bundle.js', }, plugins: [ new HtmlWebpackPlugin({ template: './src/index.html', // Ensure this file exists filename: 'index.html', alwaysWriteToDisk: true, }), new HtmlWebpackPlugin({ template: './src/another.html', // Ensure this file exists filename: 'another.html', alwaysWriteToDisk: true, }), new HtmlWebpackHarddiskPlugin({ // Optional: Set a custom output path, otherwise it uses webpack's output.path // outputPath: path.resolve(__dirname, 'build/html') }) ], devServer: { static: { directory: path.join(__dirname, 'dist'), }, compress: true, port: 9000, } };
Debug
Known issues
gotchaThe `alwaysWriteToDisk` option must be set on the `HtmlWebpackPlugin` instance(s), not on the `HtmlWebpackHarddiskPlugin` instance itself, for the functionality to be enabled.
fix
Ensure `alwaysWriteToDisk: true` is part of the `HtmlWebpackPlugin` configuration object.
affects: >=1.0.0
gotchaOnly instantiate `HtmlWebpackHarddiskPlugin` once in your `plugins` array, regardless of how many `HtmlWebpackPlugin` instances you have. Multiple instances of `HtmlWebpackHarddiskPlugin` are unnecessary and can lead to unexpected behavior.
fix
Add `new HtmlWebpackHarddiskPlugin()` only once to your `webpack.config.js` plugins array.
affects: >=1.0.0
breakingThis package requires Node.js version 10.13 or higher due to its internal dependencies and Webpack 5 compatibility. Older Node.js versions will not be supported.
fix
Upgrade your Node.js environment to version 10.13.0 or newer.
affects: <10.13.0 (Node.js)
breakingThe plugin has peer dependencies on `html-webpack-plugin` version `^5.0.0` and `webpack` version `^5.0.0`. Using older versions of these packages will result in warnings or errors.
fix
Ensure `html-webpack-plugin` and `webpack` are updated to version 5.0.0 or higher in your project dependencies.
affects: <5.0.0 (html-webpack-plugin or webpack)
Errors
Common errors & fixes
Error: Peer dependency html-webpack-plugin@^5.0.0 not found
The required peer dependency `html-webpack-plugin` is either not installed or its version does not meet the `^5.0.0` requirement.
fix
Install or update `html-webpack-plugin`: `npm install html-webpack-plugin@^5.0.0 --save-dev` or `yarn add html-webpack-plugin@^5.0.0 --dev`.
TypeError: HtmlWebpackHarddiskPlugin is not a constructor
You forgot to use the `new` keyword when instantiating the plugin in your webpack configuration.
fix
Change `plugins: [ HtmlWebpackHarddiskPlugin() ]` to `plugins: [ new HtmlWebpackHarddiskPlugin() ]`.
TypeError: Cannot read properties of undefined (reading 'apply')
This error typically occurs if the `plugins` array in your webpack configuration is not correctly defined or contains `undefined` entries, preventing Webpack from properly initializing plugins.
fix
Review your `webpack.config.js` to ensure the `plugins` array is correctly structured and all its elements are valid plugin instances.
Upgrade
Version history
2.0.0latest on npm
Audit
Dependencies
html-webpack-pluginrequiredRequired peer dependency to extend its functionality.
webpackrequiredRequired peer dependency as it's a webpack plugin.
Agent activity
4 hits · last 30 days
node
4
Resources
html-webpack-harddisk-plugin — npm install html-webpack-harddisk-plugin · libregistry