Registry / devops / webpack-hook-plugin

webpack-hook-plugin

JSON →
library1.0.7jsnpmunverified

A webpack plugin that runs shell commands at various stages of the webpack build lifecycle: on build start, on build end, on build exit, and on every compile. Version 1.0.7 is the current stable release, with no active development observed since 2023. It supports both webpack and webpack-dev-server, and allows multiple commands per hook. Unlike similar plugins (e.g., webpack-shell-plugin), this one provides a built-in 'dev' switch to avoid repeated execution in watch mode and a 'safe' mode using exec instead of spawn for compatibility.

npm install webpack-hook-plugin
INSTALL
IMPORT
SIG · WEBPACK-HOOK-PLUGI
W
webpack-hook-plugin
devopsjavascriptv1.0.7
Install
—
Import
—
Disk
—
Pass rate
0/ 6
Env Coverage0 / 6
glibc
18–22
musl
18–22
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 18–226 runs
build_error
glibc
node 18–226 runs
build_error
Code
Verified usage

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

default
✓ import WebpackHookPlugin from 'webpack-hook-plugin'
✗ const WebpackHookPlugin = require('webpack-hook-plugin').default
Has TypeScript types. Default import works with both ESM and CJS. In CJS, use `const WebpackHookPlugin = require('webpack-hook-plugin')` without .default.
WebpackHookPlugin
✓ const WebpackHookPlugin = require('webpack-hook-plugin')
✗ import { WebpackHookPlugin } from 'webpack-hook-plugin'
Named import is not available; the package exports a single default export.
type imports
✓ import type WebpackHookPlugin from 'webpack-hook-plugin'
TypeScript users can import the type for type annotations.

Shows full usage with all hooks and options in a webpack config.

const WebpackHookPlugin = require('webpack-hook-plugin'); module.exports = { plugins: [ new WebpackHookPlugin({ onBuildStart: ['echo "Webpack Start"'], onBuildEnd: ['echo "Webpack End"'], onBuildExit: ['echo "Webpack Exit"'], onCompile: ['echo "Compile step"'], dev: false, safe: false }) ] };
Debug
Known issues
gotchaThe `dev` option defaults to true, which causes scripts to execute only once in development mode (webpack-dev-server or watch). If you expect scripts to run on every rebuild, set `dev: false`.
fix
Set `dev: false` in the options object.
affects: >=1.0.0
gotchaOn Windows, the `safe` option may be necessary because `spawn` might not work correctly with shell commands. Setting `safe: true` switches to `exec` which runs in a shell.
fix
Set `safe: true` in the options object.
affects: >=1.0.0
gotchaThe `onBuildExit` hook also fires when webpack --watch finishes updating the bundle, not only when the webpack process exits. This may cause unexpected behavior if you expect it to run only once.
fix
Use `onBuildEnd` instead if you want scripts to run on every rebuild.
affects: >=1.0.0
Errors
Common errors & fixes
TypeError: WebpackHookPlugin is not a constructor
Importing as named export instead of default.
fix
Use `import WebpackHookPlugin from 'webpack-hook-plugin'` or `const WebpackHookPlugin = require('webpack-hook-plugin')`.
Error: spawn ENOENT
The `safe` option is false (default), using spawn which may not find the shell on some systems.
fix
Set `safe: true` in the options to use exec instead.
Upgrade
Version history
1.0.7latest on npm
Audit
Dependencies

No dependency data recorded yet.

Agent activity
11 hits · last 30 days
node
10
Resources
webpack-hook-plugin — npm install webpack-hook-plugin · libregistry