Registry / devops / webpack-build-notifier

webpack-build-notifier

JSON →
library3.1.0jsnpmunverified

The webpack-build-notifier package is a Webpack plugin designed to provide OS-level notifications for various build events, leveraging the `node-notifier` library. It informs developers about compilation warnings, errors, successful completions, and the start of a compilation process directly through desktop notifications, reducing the need to constantly monitor the terminal. The current stable version is 3.1.0, which introduced official ESM support and refined CJS default exports. Previous major version 3.0.0 brought essential compatibility with Webpack 5. This package maintains a steady release cadence, primarily driven by Webpack version updates and crucial bug fixes. Its key differentiators include extensive configuration options for notification titles, custom logos, distinct sounds for different build outcomes (success, warning, failure, compilation start), and the ability to suppress specific notification types, making it highly adaptable to individual developer workflows and preferences. This allows for a more focused development experience, instantly alerting to build issues.

npm install webpack-build-notifier
INSTALL
IMPORT
SIG · WEBPACK-BUILD-NOTI
W
webpack-build-notifier
devopsjavascriptv3.1.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.

WebpackBuildNotifierPlugin
import WebpackBuildNotifierPlugin from 'webpack-build-notifier';
import { WebpackBuildNotifierPlugin } from 'webpack-build-notifier';
Since v3.1.0, the package provides a proper ESM default export. For versions prior to v3.1.0, or in certain bundler configurations, a CommonJS `require` was often more reliable for this default export.
WebpackBuildNotifierPlugin (CommonJS)
const WebpackBuildNotifierPlugin = require('webpack-build-notifier');
const { WebpackBuildNotifierPlugin } = require('webpack-build-notifier');
This is the standard CommonJS import pattern, supported in all versions. The plugin exports itself as the default object.

This quickstart demonstrates how to integrate `webpack-build-notifier` into a Webpack configuration, including common options for custom titles, logos, sound control, and suppressing success notifications.

const path = require('path'); const WebpackBuildNotifierPlugin = require('webpack-build-notifier'); module.exports = { mode: 'development', // Or 'production' entry: './src/index.js', output: { filename: 'bundle.js', path: path.resolve(__dirname, 'dist'), }, plugins: [ new WebpackBuildNotifierPlugin({ title: "My Awesome Webpack Project", // Provide an absolute path to your project's logo for professional-looking notifications. logo: path.resolve(__dirname, "./public/favicon.png"), // Ensure this path is correct suppressSuccess: true, // Only notify on warnings and errors, not successful builds suppressWarning: false, // Keep warnings visible suppressError: false, // Definitely show errors // Customize sounds for different build outcomes successSound: false, // No sound for success, as we suppress it warningSound: 'Bottle', // A distinct sound for warnings failureSound: 'Basso', // A serious sound for build failures // You can also add callbacks for build events onCompileStart: (compilation) => { console.log('Webpack compilation started!'); }, onComplete: (compilation) => { if (compilation.errors.length > 0) { console.error('Build completed with errors!'); } else if (compilation.warnings.length > 0) { console.warn('Build completed with warnings!'); } else { console.log('Build completed successfully!'); } } }) ], devtool: 'eval-source-map', // Recommended for development };
Debug
Known issues
breakingVersion 3.0.0 of `webpack-build-notifier` dropped support for Webpack versions older than 5.
fix
Upgrade your Webpack installation to version 5 or higher. If you must use an older Webpack, pin `webpack-build-notifier` to version 2.x.
affects: <3.0.0
gotchaThe `logo` option requires an absolute file path to the image. Using relative paths will result in an error or the logo not appearing.
fix
Always use `path.resolve(__dirname, './path/to/logo.png')` or similar methods to provide an absolute path to your logo file.
affects: >=1.0.0
gotchaBy default, notifications are generated for success, warnings, and errors. During active development, success notifications can be frequent and disruptive.
fix
Set the `suppressSuccess: true` option in the plugin configuration to prevent success notifications, focusing only on warnings and errors.
affects: >=1.0.0
gotchaSince v3.1.0, `webpack-build-notifier` provides a proper ESM default export. If using ESM and importing via named imports (e.g., `import { WebpackBuildNotifierPlugin } from 'webpack-build-notifier'`), it might lead to `undefined` or incorrect plugin instantiation.
fix
For ESM, always use the default import: `import WebpackBuildNotifierPlugin from 'webpack-build-notifier';`.
affects: >=3.1.0
Errors
Common errors & fixes
TypeError: WebpackBuildNotifierPlugin is not a constructor
Attempting to use `require` or `import` in a way that doesn't resolve to the plugin constructor, often by using named imports instead of default.
fix
For CommonJS, use `const WebpackBuildNotifierPlugin = require('webpack-build-notifier');`. For ESM (v3.1.0+), use `import WebpackBuildNotifierPlugin from 'webpack-build-notifier';`.
Error: WebpackBuildNotifierPlugin: logo option must be an absolute path.
The `logo` configuration option was provided with a relative path.
fix
Ensure the `logo` option uses an absolute path, for example, `logo: path.resolve(__dirname, './public/logo.png')`. Remember to `require('path')` if needed.
TypeError: WebpackBuildNotifierPlugin is not a plugin (expected to be an instance of a plugin)
The plugin was added to Webpack's `plugins` array without being instantiated using the `new` keyword.
fix
When adding the plugin to your `webpack.config.js`, ensure it's instantiated: `new WebpackBuildNotifierPlugin({...options})`.
Upgrade
Version history
3.1.0latest on npm
Audit
Dependencies
webpackrequiredRequired as a peer dependency for Webpack plugin functionality.
Agent activity
8 hits · last 30 days
node
8
Resources