From 0816b78670a0ad77aa964305ea165a81c21148dc Mon Sep 17 00:00:00 2001 From: kzc Date: Fri, 19 May 2017 00:41:29 -0400 Subject: [PATCH] add minify warnings example --- README.md | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index a7635095..e0d959fa 100644 --- a/README.md +++ b/README.md @@ -319,9 +319,20 @@ var result = UglifyJS.minify({ console.log(result.code); ``` +To produce warnings: +``` +var result = UglifyJS.minify("function f(){ var u; return 5; }", { + warnings: true +}); +console.log(result.code); // function f(){return 5} +console.log(result.warnings); // [ 'Dropping unused variable u [0:1,18]' ] +console.log(result.error); // runtime error, not defined in this case +``` + ## Minify options -- `warnings` (default `false`) — pass `true` to display compressor warnings. +- `warnings` (default `false`) — pass `true` to return compressor warnings + in `result.warnings`. Use the value `"verbose"` for more detailed warnings. - `parse` (default `{}`) — pass an object if you wish to specify some additional [parse options](#parse-options).