This plugin will transform code in mainly two ways - 1) Reduce as much statements as possible into expressions, and 2) Make expressions as uniform as possible for better compressibility
In
function foo() {
if (x) a();
}
function foo2() {
if (x) a();
else b();
}
Out
function foo() {
x && a();
}
function foo2() {
x ? a() : b();
}
In
undefined foo['bar'] Number(foo)
Out
void 0 foo.bar +foo
npm install babel-plugin-minify-simplify
.babelrc (Recommended).babelrc
{
"plugins": ["minify-simplify"]
}
babel --plugins minify-simplify script.js
require("babel-core").transform("code", {
plugins: ["minify-simplify"]
});
© 2018 Sebastian McKenzie
Licensed under the MIT License.
http://babeljs.io/docs/plugins/minify-simplify/