Giter Club home page Giter Club logo

compilation-notification-fix's Introduction

webpack-build-notifier

A Webpack plugin that uses the node-notifier module to display OS-level notifications for Webpack build errors and warnings.

NPM version

webpack-build-notifier-errorwebpack-build-notifier-success

Are you tired of having to constantly switch between your IDE and terminal window to see whether your latest edits resulted in a failed build? Why didn't your latest changes get hot-loaded? Was there a syntax error or failed unit test? With this plugin, you will always be apprised of build problems without having to keep an eye on your terminal window.

To use, install the webpack-build-notifier package npm install webpack-build-notifier --save-dev and add the plugin to your Webpack configuration file:

// webpack.config.js
var WebpackBuildNotifierPlugin = require('webpack-build-notifier');

module.exports = {
  // ... snip ...
  plugins: [
    new WebpackBuildNotifierPlugin({
      title: "My Project Webpack Build",
      logo: path.resolve("./img/favicon.png"),
      suppressSuccess: true
    })
  ],
  // ... snip ...
}

Config Options

title

The notification title. Defaults to Webpack Build.

logo

The absolute path to the project logo to be displayed as a content image in the notification. Optional.

sound

The sound to play for notifications. Set to false to play no sound. Valid sounds are listedin the node-notifier project, here. Defaults to Submarine.

successSound

The sound to play for success notifications. Defaults to the value of the sound configuration option. Set to false to play no sound for success notifications. Takes precedence over the sound configuration option.

warningSound

The sound to play for warning notifications. Defaults to the value of the sound configuration option. Set to false to play no sound for warning notifications. Takes precedence over the sound configuration option.

failureSound

The sound to play for failure notifications. Defaults to the value of the sound configuration option. Set to false to play no sound for failure notifications. Takes precedence over the sound configuration option.

compilationSound

The sound to play for compilation notifications. Defaults to the value of the sound configuration option. Set to false to play no sound for compilation notifications. Takes precedence over the sound configuration option.

suppressSuccess

Defines when success notifications are shown. Can be one of the following values:

  • false - Show success notification for each successful compilation (default).
  • true - Only show success notification for initial successful compilation and after failed compilations.
  • "always" - Never show the success notifications.
  • "initial" - Same as true, but suppresses the initial success notification.

suppressWarning

True to suppress the warning notifications, otherwise false (default).

suppressCompileStart

True to suppress the compilation started notifications (default), otherwise false.

activateTerminalOnError

True to activate (focus) the terminal window when a compilation error occurs. Note that this only works on Mac OSX (for now). Defaults to false. Regardless of the value of this config option, the terminal window can always be brought to the front by clicking on the notification.

successIcon

The absolute path to the icon to be displayed for success notifications. Defaults to the included ./icons/success.png.

Success

warningIcon

The absolute path to the icon to be displayed for warning notifications. Defaults to the included ./icons/warning.png.

Warning

failureIcon

The absolute path to the icon to be displayed for failure notifications. Defaults to the included ./icons/failure.png.

Failure

compileIcon

The absolute path to the icon to be displayed for compilation started notifications. Defaults to the included ./icons/compile.png.

Compile

messageFormatter

A function which returns a formatted notification message. The function is passed two parameters:

  • {Object} error/warning - The raw error or warning object.
  • {String} filepath - The path to the file containing the error/warning (if available).

This function must return a String. The default messageFormatter will display the filename which contains the error/warning followed by the error/warning message. Note that the message will always be limited to 256 characters.

notifyOptions

Any additional node-notifier options as documented in the node-notifer documentation. Note that options provided here will only be applied to the success/warning/error notifications (not the "compilation started" notification). The title, message, sound, contentImage (logo), and icon options will be ignored, as they will be set via the corresponding WebpackBuildNotifier config options (either user-specified or default).

onClick

A function called when the notification is clicked. By default it activates the Terminal application.

onTimeout

A function called when the notification times out and is closed. Undefined by default.

Future Improvements

  • TBD

Notes

After publishing this package I discovered a couple other similar plugins that are worth looking into:

Given the purpose and similarities, this project probably should have been a fork of one of these.

Changelog

View the changelog here.

compilation-notification-fix's People

Contributors

blvz avatar codeuniquely avatar mortenhoustonludvigsen avatar progm avatar roccoc avatar rohn avatar sergey-behavox avatar tgrelka avatar wisebird avatar

Watchers

 avatar

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.