survivejs / webpack-book

From apprentice to master (CC BY-NC-ND)
https://survivejs.com/webpack/
2.42k stars 319 forks source link

Analyzing Build Statistics - stats.json & webpack validator #79

Closed vjancik closed 8 years ago

vjancik commented 8 years ago

http://survivejs.com/webpack/building-with-webpack/analyzing-build-statistics/ Validate config plugin adds this line to the top of stats.json file: [webpack-validator] Config is valid.

and makes the stats.json file invalid for use with the online tool (unless you remove the first line). Didn't try the standalone tool.

Not sure what's the easiest fix, maybe piping the output in package.json to some linux text util to remove the first line, then piping it to stats.json

bebraw commented 8 years ago

Good point.

I think I'll rethink the validator configuration so that we'll get a npm script to run. The validator includes a cli so we'll end up with something like "test:validate": "webpack-validator" though there's the problem of digging out the configuration paths to validate (needs development on validator side).

There can also be a flag so you could do something like VALIDATE=true npm start so that validation becomes opt-in.

Thanks for the report again. 👍

jonathanglasmeyer commented 8 years ago

Good point. Well that option would be easy to implement. Care to PR? Should probably be called "quiet", no?

bebraw commented 8 years ago

@jonathanewerner Yeah, I will PR quiet. Easy enough.

nyrosmith commented 8 years ago

I just merged the PR from @bebraw. webpack-validator has now a new option 'quiet'

Quiet Mode If you want to mute console output apart from errors, set --quiet or validate(config, yourSchema, {quiet: true}). This is particularly useful if you are using webpack --json as you'll want to avoid writing additional text to the JSON output.

bebraw commented 8 years ago

I opened two new related issues: https://github.com/js-dxtools/webpack-validator/issues/72, https://github.com/js-dxtools/webpack-validator/issues/73 . We can do a little better. 👍