jstransformer-uglify-es
v0.2.1
Published
UglifyES support for JSTransformers
Downloads
68
Maintainers
Readme
jstransformer-uglify-es
uglify-es support for jstransformer
Installation
npm install jstransformer-uglify-es
API
Initialization
let jstransformer = require("jstransformer");
let uglify = jstransformer(require("jstransformer-uglify-es"));
let options = {
compress: {
toplevel: true
}
}
More about uglify-es minify options.
.render(code[, options])
let code = "var x = 5; var y = 6; console.log(x + y);";
let result = uglify.render(code, options);
result.body // -> "console.log(11);"
.renderFile(filePath[, options])
// test.js
let foo = 4;
let bar = 8;
const add = function(a, b) {
return a + b;
}
console.log(add(foo, bar));
// index.js
let result = uglify.renderFile("test.js", options);
result.body // -> "console.log(function(n,o){return n+o}(4,8));"
.renderAsync(code[, options])
The same as .render
but return new Promise.
.renderFileAsync(filePath[, options])
The same as .renderFile
but return new Promise.
Pug filter
script
include:uglify-es(compress={toplevel:true}) my-script.js