From 4ba9aff78b516345db59e409c7d8896fa9f2e2e1 Mon Sep 17 00:00:00 2001 From: kzc Date: Sun, 21 May 2017 14:28:31 -0400 Subject: [PATCH] add another minify() options example --- README.md | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/README.md b/README.md index f788baa1..8b6a800e 100644 --- a/README.md +++ b/README.md @@ -335,6 +335,29 @@ var result = UglifyJS.minify(code, options); console.log(result.code); // console.log(function(n,o){return n+o}(3,7)); ``` +An example of a combination of `minify()` options: +```javascript +var code = { + "file1.js": "function add(first, second) { return first + second; }", + "file2.js": "console.log(add(1 + 2, 3 + 4));" +}; +var options = { + toplevel: true, + compress: { + global_defs: { + "@console.log": "alert" + }, + passes: 2 + }, + output: { + beautify: false, + preamble: "/* uglified */" + } +}; +var result = UglifyJS.minify(code, options); +console.log(JSON.stringify(result.code)); // "/* uglified */\nalert(10);" +``` + To produce warnings: ```javascript var code = "function f(){ var u; return 2 + 3; }";