Skip to content

ktalebian/format-webpack-messages

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

15 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

@k88/format-webpack-messages

Taken from react-dev-utils, but is published as a standalone package and has Typescript definition.

Installation

Install using

npm install @k88/format-webpack-messages

Usage

Use this to format webpack warnings/errors:

const webpack = require('webpack');
const formatMessages = require('@k88/webpack-format-messages');

const compiler = webpack(/* webpack-config */);

compiler.hooks.done.tap('done', (stats) => {
  const isSuccessful = stats.hasErrors() || stats.hasWarnings();
  
  if (!isSuccessful) {
    const messages = formatMessages(stats);

    if (messages.errors.length) {
      console.log('Failed to compile.');
      messages.errors.forEach(e => console.log(e));
    }

    if (messages.warnings.length) {
      console.log('Compiled with warnings.');
      messages.warnings.forEach(w => console.log(w));
    }  
  }
});

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published