Skip to content
This repository has been archived by the owner on Jul 27, 2021. It is now read-only.

Plugin makes webpack --json output invalid #53

Open
manuelbieh opened this issue Jun 6, 2017 · 1 comment
Open

Plugin makes webpack --json output invalid #53

manuelbieh opened this issue Jun 6, 2017 · 1 comment

Comments

@manuelbieh
Copy link

Hi,

when using friendly-errors-webpack-plugin with webpack --json the generated JSON is invalid:

 DONE  Compiled successfully in 21858ms12:59:37

{
  "errors": [],
  "warnings": [],
  "version": "2.3.2",
  "hash": "0837132c83435ec275e9",
  "time": 21858,
  "publicPath": "/",
...

Maybe you can add a check if --json flag is set and omit the compilation message? Otherwise it's impossible to pipe the webpack --json output to other tools such as webpack-bundle-size-analyzer:

$ webpack --json | webpack-bundle-size-analyzer
Error: The input is not valid JSON.

Check that:
 - You passed the '--json' argument to 'webpack'
 - There is no extra non-JSON content in the output, such as log messages.

The parsing error was:

  SyntaxError: Unexpected token D in JSON at position 1
@manuelbieh
Copy link
Author

manuelbieh commented Jun 6, 2017

https://github.com/geowarin/friendly-errors-webpack-plugin/blob/master/src/output.js#L52

Changing this line to

if (this.enabled && process.argv.indexOf('--json') === -1) {

solves my problem for now.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant