diff --git a/README.md b/README.md index c093297..db8f73b 100644 --- a/README.md +++ b/README.md @@ -25,6 +25,36 @@ Output file is generated in the current directory. It will contain minified file > uglifymyjs —version ``` +# Usage Example +See [Sample](./Sample). + +# Dependency +The tool is built on top of `uglifyjs-webpack-plugin`. Following is the fixed configuration currently it is using. Feel free add new issues if you want any customization. +``` +{ + cache: false, + parallel: true, + uglifyOptions: { + compress: { + drop_console: true, + warnings: false, + }, + toplevel: true, + keep_classnames: undefined, + keep_fnames: false, + nameCache: null, + output: { + beautify: false, + comments: false, + }, + compress: true, + ecma: 6, + mangle: true, + }, + sourceMap: true, +} +``` + # Contributing This library is designed to support JS files - i you want to add a new language support, we'd love you to contribute them here. @@ -33,6 +63,8 @@ Please see [Coding Guidelines](https://github.com/nishantmendiratta/uglify-my-js File issues in the **Issues** tab in GitHub + + # Changelog See [CHANGELOG](./CHANGELOG.md). diff --git a/package.json b/package.json index 1412b61..b79fc43 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "uglify-my-js", - "version": "1.1.12", + "version": "1.1.13", "description": "Simple cli tool to minify javascript a file", "main": "bin/index.js", "bin": { diff --git a/sample.js b/sample.js deleted file mode 100644 index dfdbaa2..0000000 --- a/sample.js +++ /dev/null @@ -1 +0,0 @@ -console.log('sample'); \ No newline at end of file diff --git a/sample/index.html b/sample/index.html new file mode 100644 index 0000000..a17fc76 --- /dev/null +++ b/sample/index.html @@ -0,0 +1,32 @@ + + + + + + + Sample HTML + + +
+ + + \ No newline at end of file diff --git a/sample/main.bundle.min.js b/sample/main.bundle.min.js new file mode 100644 index 0000000..ca8152d --- /dev/null +++ b/sample/main.bundle.min.js @@ -0,0 +1,2 @@ +var e;e=window,appendNewElementToRoot=function(e){var o,n;e&&(o=document.createElement("h1"),n=document.createTextNode("Hello From H1"),o.appendChild(n),e.appendChild(o))},e.myThirdPartyLib={appendNewElementToRoot:appendNewElementToRoot}; +//# sourceMappingURL=main.bundle.min.js.map \ No newline at end of file diff --git a/sample/main.bundle.min.js.map b/sample/main.bundle.min.js.map new file mode 100644 index 0000000..5168ad4 --- /dev/null +++ b/sample/main.bundle.min.js.map @@ -0,0 +1 @@ +{"version":3,"sources":["webpack:///../users/nishantmendiratta/documents/playground/uglify-my-js/sample/sample.js"],"names":["window","appendNewElementToRoot","element","h1","textNode","document","createElement","createTextNode","appendChild","myThirdPartyLib"],"mappings":"IAAWA,IAaRA,OAZDC,uBAAyB,SAAUC,GACjC,IAIMC,EACAC,EALDF,IAICC,EAAKE,SAASC,cAAc,IAAI,EAChCF,EAAWC,SAASE,eAAe,eAAe,EACxDJ,EAAGK,YAAYJ,CAAQ,EACvBF,EAAQM,YAAYL,CAAE,EACxB,EAEAH,EAAOS,gBAAkB,CAACR,6CAAsB","file":"main.bundle.min.js","sourcesContent":["(function (window) {\n appendNewElementToRoot = function (element) {\n if (!element) {\n return;\n }\n\n const h1 = document.createElement('h1');\n const textNode = document.createTextNode('Hello From H1');\n h1.appendChild(textNode);\n element.appendChild(h1);\n };\n\n window.myThirdPartyLib = {appendNewElementToRoot};\n})(window);\n\n"],"sourceRoot":""} \ No newline at end of file diff --git a/sample/sample.js b/sample/sample.js new file mode 100644 index 0000000..bca4025 --- /dev/null +++ b/sample/sample.js @@ -0,0 +1,15 @@ +(function (window) { + appendNewElementToRoot = function (element) { + if (!element) { + return; + } + + const h1 = document.createElement('h1'); + const textNode = document.createTextNode('Hello From H1'); + h1.appendChild(textNode); + element.appendChild(h1); + }; + + window.myThirdPartyLib = {appendNewElementToRoot}; +})(window); +