GithubHelp home page GithubHelp logo

webpack-notifier's Introduction

webpack-notifier

npm Version GitHub Workflow Status Coverage Status Code Style
npm npm bundle size

This is a webpack plugin that uses the node-notifier package to display build status system notifications to the user.

webpack-notifier screenshot

This is a fork of the webpack-error-notification plugin. It adds support for Windows and there is no need to manually install the terminal-notifier package on OS X anymore.

The plugin will notify you about the first run (success/fail), all failed runs and the first successful run after recovering from a build failure. In other words: it will stay silent if everything is fine with your build.

Installation

Use npm to install this package:

npm install --save-dev webpack-notifier

Check the node-notifier Requirements whether you need to install any additional tools for your OS.

Usage

In the webpack.config.js file:

var WebpackNotifierPlugin = require('webpack-notifier');

var config = module.exports = {
  // ...

  plugins: [
    new WebpackNotifierPlugin(),
  ]
}

Configuration

All node-notifier options

You can use any node-notifier options (depending on your OS) Except for options generated by the plugin itself:

  • title - it can be not only a string, but also a function
  • message - generated based on the value of other options
  • contentImage - it can be an object with images for different statuses
  • icon - matches with contentImage

Title

Title shown in the notification.

new WebpackNotifierPlugin({title: 'Webpack'});
new WebpackNotifierPlugin({title: function (params) {
  return `Build status is ${params.status} with message ${params.message}`;
}});

Emojis in message text

Show status emoji icon before the message.

new WebpackNotifierPlugin({emoji: true});

Content Image

Image shown in the notification. Can be a path string or object with paths.

String path:

var path = require('path');

new WebpackNotifierPlugin({contentImage: path.join(__dirname, 'logo.png')});

Object string path:

var path = require('path');

const statusesPaths = {
  success: path.join(__dirname, 'success.png'),
  warning: path.join(__dirname, 'warning.png'),
  error: path.join(__dirname, 'error.png')
}

new WebpackNotifierPlugin({contentImage: statusesPaths});

Exclude Warnings

If set to true, warnings will not cause a notification.

new WebpackNotifierPlugin({excludeWarnings: true});

Always Notify

Trigger a notification every time. Call it "noisy-mode".

new WebpackNotifierPlugin({alwaysNotify: true});

Notify on error

Trigger a notification only on error.

new WebpackNotifierPlugin({onlyOnError: true});

Skip Notification on the First Build

Do not notify on the first build. This allows you to receive notifications on subsequent incremental builds without being notified on the initial build.

new WebpackNotifierPlugin({skipFirstNotification: true});

webpack-notifier's People

Contributors

a-x- avatar carlsverre avatar etlovett avatar gerkindev avatar gvozd avatar hlhc avatar inoyakaigor avatar joernb avatar johnnyreilly avatar martijnrusschen avatar mikaelbr avatar naidraikzir avatar opensrcken avatar pavlin99th avatar petrbela avatar rkoval avatar robertborg avatar s00d avatar tjunnone avatar turbo87 avatar vsolovyov avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar

webpack-notifier's Issues

NPM Package Missing Type Declarations

Just found this project and trying it from NPM today. Had to use an older version (1.13.0) due to the latest release producing an error with Visual Studio and Typescript - the package.json file for version 1.14.0 says there is a index.d.ts file in the package to use for typings but this file is missing from the bundle on NPM.

Version 1.13.0 does not have the save issue - the package also lacks a typings .d.ts file but the package.json in that package doesn't declare that the package contains any typings.

Update node-notifier

Hello,

The current version of the marked library that this lib depends on is tagged as having security vulnerabilities.

I think updating the node-notifier package removes the dependency, and thus resolving the issue.

Yarn watch dies on warning after first pass

I'm using this as part of Laravel Mix 2.1.11, but I've isolated the problem to this plugin, the Webpack Stats object, or the former's use of the latter. Compiling our JS/SASS produces a warning on the initial run of yarn watch due to an image URL it thinks doesn't exist which is fine. Changing a SASS file causes the build to rerun, but this time the process halts with a type error "trying to access 'module' of undefined."

Line 28 sees that stats.hasWarnings() returns true, and line 29 sets error to the first element of the stats.compilation.warnings array, but this array is empty. Line 42 then tries to access error.module which kills the process.

I inserted the following before line 39:

// Fix "yarn watch"
if (!error) {
    console.log(stats.hasErrors());
    console.log(stats.compilation.errors);
    console.log(stats.hasWarnings());
    console.log(stats.compilation.warnings);
    return 'Build successful';
}

This lets the build proceed after printing this:

false
[]
true
[]

Are there other sources of warnings besides the compilation object? If not, it looks like Webpack may actually be at fault here, but I don't know the Webpack codebase or API at all. Either way, it probably makes sense to check that error is truthy before accessing its properties.

I went with this solution for now before line 39:

// Fix "yarn watch"
if (!error) {
    return 'Unknown ' + (stats.hasErrors() ? 'error' : 'warning');
}

Dependency vulnerability

Hi,

The package node-notifier (prior to 5.0.0) has a known security vulnerability due to the use of the package 'cli-usage' (prior to 0.1.7) that use the 'marked' (prior to 0.3.9) package.

│ ├─┬ [email protected]
│ │ ├─┬ [email protected]
│ │ │ ├─┬ [email protected]
│ │ │ │ ├── [email protected] (vulnerabbility prior to 0.3.9)

Consider upgrading to node-notifier @5.0.0 or overriding nested dependency version.

Quentin Pétel

Webpack 2 support?

I c the example uses webpack 1

Is there a roadmap for webpack 2 support?

I could take a swing at it with some directions :)

Fatal error: Cannot read property 'rawRequest' of undefined

Fatal error: Cannot read property 'rawRequest' of undefined
TypeError: Cannot read property 'rawRequest' of undefined
    at WebpackNotifierPlugin.compileMessage (/Users/tom/Documents/magicland/auth.comet.is/node_modules/webpack-notifier/index.js:29:31)
    at WebpackNotifierPlugin.compilationDone (/Users/tom/Documents/magicland/auth.comet.is/node_modules/webpack-notifier/index.js:39:20)
    at Tapable.applyPlugins (/Users/tom/Documents/magicland/auth.comet.is/node_modules/webpack/node_modules/tapable/lib/Tapable.js:26:37)
    at Tapable.<anonymous> (/Users/tom/Documents/magicland/auth.comet.is/node_modules/webpack/lib/Compiler.js:191:12)
    at FSReqWrap.oncomplete (fs.js:99:15)

Added simply with plugins: [ new WebpackNotifierPlugin({title: 'server build'}) ]

webpack encore enableBuildNotifications --watch

Hey guys,

I am using webpack encore with symfony.

I enable the enableBuildNotifications and the notification appears when first build is done, but when I use --watch I didn'te receive any notification.

I have tried also send alwaysNotify as the argument of enableBuildNotifications() method, but also didn't work so far.

Anyone figure what happening ?
Thanks in advance.

Fix npm version issues with 1.3.0/1.3.1

npm outdated keeps saying:

Package           Current  Wanted  Latest  Location
webpack-notifier    1.3.0   1.3.1   1.3.0  myapp

When I check https://www.npmjs.com/package/webpack-notifier it says 1.3.0 is the latest version. Listing creation times for the package shows 1.3.0 coming after 1.3.1:

$ npm view webpack-notifier time

{ modified: '2016-02-22T13:11:25.705Z',
  created: '2015-02-12T11:40:26.317Z',
  '1.0.0': '2015-02-12T11:40:26.317Z',
  '1.0.1': '2015-02-12T21:30:56.211Z',
  '1.1.0': '2015-02-27T11:31:46.128Z',
  '1.1.1': '2015-02-27T20:09:58.777Z',
  '1.2.0': '2015-03-15T09:07:59.019Z',
  '1.2.1': '2015-04-16T07:07:11.887Z',
  '1.3.1': '2016-02-22T13:11:11.249Z',
  '1.3.0': '2016-02-22T13:11:25.705Z' }

It looks like the only change in 1.3.1 was to "republish to npm" but that's somehow causing the version mismatch now. It might just need a version bump (1.3.2?) and push to npm to fix this?

Notifications not showing up on Windows 10

After updating to Windows 10 1903 or newer version, notifications stopped popping up. Actually the first notification shows up as expected but all subsequent notifications keep getting queued (or something) and they show up all at once in the notification area after a machine reboot.

It seems that updating node-notifier to v6 solves the issue. See here.

Webpack 4 support

When webpack-notifier is used with webpack 4 (tested with 4.1.0), a deprecation warning is issued:

(node:23649) DeprecationWarning: Tapable.plugin is deprecated. Use new API on .hooks instead

Error when using postcss-loader: "Cannot read property 'module' of undefined"

I'm using Webpack Encore 0.22.2 with Webpack 4.28.3 and webpack-notifier 1.6.0. After including postcss-loader version 3, suddenly there is this error:

$ encore production
Running webpack ...

  WARNING   Webpack is already provided by Webpack Encore, also adding it to your package.json file may cause issues.
TypeError: Cannot read property 'module' of undefined
	at module.exports.WebpackNotifierPlugin.compileMessage (my_project_root_dir\node_modules\webpack-notifier\index.js:42:15)
	at module.exports.WebpackNotifierPlugin.compilationDone (my_project_root_dir\node_modules\webpack-notifier\index.js:57:20)
	at AsyncSeriesHook.eval [as callAsync] (eval at create (my_project_root_dir\node_modules\tapable\lib\HookCodeFactory.js:32:10), <anonymous>:9:1)
	at AsyncSeriesHook.lazyCompileHook (my_project_root_dir\node_modules\tapable\lib\Hook.js:154:20)
	at emitRecords.err (my_project_root_dir\node_modules\webpack\lib\Compiler.js:257:22)
	at Compiler.emitRecords (my_project_root_dir\node_modules\webpack\lib\Compiler.js:371:39)
	at emitAssets.err (my_project_root_dir\node_modules\webpack\lib\Compiler.js:251:10)
	at hooks.afterEmit.callAsync.err (my_project_root_dir\node_modules\webpack\lib\Compiler.js:357:14)
	at _err0 (eval at create (my_project_root_dir\node_modules\tapable\lib\HookCodeFactory.js:32:10), <anonymous>:20:1)
	at my_project_root_dir\node_modules\assets-webpack-plugin\dist\index.js:148:9
	at my_project_root_dir\node_modules\assets-webpack-plugin\dist\lib\output\createQueuedWriter.js:16:7
	at my_project_root_dir\node_modules\assets-webpack-plugin\dist\lib\output\createOutputWriter.js:74:13
	at my_project_root_dir\node_modules\graceful-fs\graceful-fs.js:45:10
	at FSReqWrap.oncomplete (fs.js:135:15)
error Command failed with exit code 1.

Deactivating the build notifications solves the problem, but then I have no build notifications.

I debugged the script at line 25, in this case error really is undefined, this.lastBuildSucceeded is false, stats.hasErrors() is false, but stats.hasWarnings() is true. Yet, stats.compilation.warnings is an empty array.

Exclude Success

Is it possible to only show the notification if there is an error?

Don't like having the pop in every time I save my file.

Does not work - Cannot read property 'mangleWasmImports' of undefined

Ubuntu 22.04

[webpack-cli] TypeError: Cannot read property 'mangleWasmImports' of undefined
    at EnableWasmLoadingPlugin.apply (/path/node_modules/webpack/lib/wasm/EnableWasmLoadingPlugin.js:79:52)
    at WebpackOptionsApply.process (/path/node_modules/webpack/lib/WebpackOptionsApply.js:223:39)
    at createCompiler (/path/node_modules/webpack/lib/webpack.js:80:28)
    at create (/path/node_modules/webpack/lib/webpack.js:134:16)
    at webpack (/path/node_modules/webpack/lib/webpack.js:142:47)
    at WebpackCLI.f [as webpack] (/path/node_modules/webpack/lib/index.js:64:16)
    at WebpackCLI.createCompiler (/path/node_modules/webpack-cli/lib/webpack-cli.js:1789:29)
    at async WebpackCLI.runWebpack (/path/node_modules/webpack-cli/lib/webpack-cli.js:1890:20)
    at async Command.<anonymous> (/path/node_modules/webpack-cli/lib/webpack-cli.js:912:21)
    at async Promise.all (index 1)

No icon on Windows

No icon displayed on WIndows - you see this:

noicon

It would be nice to see an icon like this:

image

Icon not showing (Linux/Elementary OS)

Hello, I have a file called 'logo.png' in my webpack directory. I read the source and know that this is the default, but either not setting it in options or passing it explicit does not make the icon show in the notification. I tried with .jpg, .svg and .png with no success. I'm running Elementary OS. Is there a way to fix it?

Option to only notify when "status" has changed

Since I have my editor set to auto save after x sec I'm getting many error notifications during typing.

Therefore I'd love to see an option to only get notified when the status changes (e.g. from success --> error or the other way around) but not for subsequent errors.

Suppress Terminal Icon (macOS)

I have the following configuration

    new WebpackNotifierPlugin({
      title: 'Webpack DIY Build Status',
      excludeWarnings: true,
      icon: path.join(__dirname, 'resources/assets/logo.png')
    }),

and all works as expected. However, I am curious if it possible to suppress the small terminal icon that is part of the title (only appears when I have customized the icon property

image

Notifier Doesn't Always Show

Setup:
webpack 3.12.0
npm 6.4.1
node 8.9.4
Visual Studio 2015 Update 3
WebPack Task Runner 1.5.94
Windows 10

I have no idea how to reliably reproduce this, but sometimes the notification popup never shows up after webpack finishes a build. Once it stops showing up, the only way to get it to show up again is to restart Visual Studio, and sometimes that doesn't even work.

Anyone else experience this issue?

Know how to fix it?

UnhandledPromiseRejectionWarning: Error: spawn ENAMETOOLONG

If I use this plugin in my codebase I get the following error:

UnhandledPromiseRejectionWarning: Error: spawn ENAMETOOLONG

at _errnoException (util.js:992:11)
at ChildProcess.spawn (internal/child_process.js:323:11)
at exports.spawn (child_process.js:502:9)
at Object.exports.execFile (child_process.js:212:15)
at Object.module.exports.fileCommand (...\node-notifier\lib\utils.js:69:13)
at WindowsToaster.notify (...\node_modules\node-notifier\notifiers\toaster.js:94:9)
at module.exports.WebpackNotifierPlugin.compilationDone (...\node_modules\webpack-notifier\index.js:62:18)
at args (...\node_modules\speed-measure-webpack-plugin\WrappedPlugin\index.js:52:19)

If I disable this plugin, the errors goes away without any problems.

I am open to contribute on this issue. Where could the problem be?

Does not work on Ubuntu 18.04

We have a React project using some additional technologies (eg TS, webpack, redux-saga, and so on).
We installed this plugin and the effect on Ubuntu 18.04 was only one timer (notification popped up once).
Next webpack runs (TypeScript code recompilations fired on file change) don't trigger further notifications...
How to debug this issue on Ubuntu?

marek@marek-Latitude-3470:~$ sudo apt install notify-osd
Reading package lists... Done
Building dependency tree       
Reading state information... Done
notify-osd is already the newest version (0.9.35+16.04.20160415-0ubuntu2).
The following packages were automatically installed and are no longer required:
  linux-headers-4.13.0-39 linux-headers-4.13.0-39-generic linux-image-4.13.0-39-generic linux-image-extra-4.13.0-39-generic
Use 'sudo apt autoremove' to remove them.
0 upgraded, 0 newly installed, 0 to remove and 0 not upgraded.
marek@marek-Latitude-3470:~$ sudo apt install libnotify-bin
Reading package lists... Done
Building dependency tree       
Reading state information... Done
libnotify-bin is already the newest version (0.7.7-3).
The following packages were automatically installed and are no longer required:
  linux-headers-4.13.0-39 linux-headers-4.13.0-39-generic linux-image-4.13.0-39-generic linux-image-extra-4.13.0-39-generic
Use 'sudo apt autoremove' to remove them.
0 upgraded, 0 newly installed, 0 to remove and 0 not upgraded.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.