BABEL-MINIFY(1)
π NAME π
babel-minify β an ES6+ aware minifier based on the Babel toolchain β¨
okay bestie, listen. this is the manual page for babel-minify(1), from the User Commands girlies. she minifies your code and she's very ES6+ aware. periodt.
πΈ DESCRIPTION πΈ
so the whole vibe is this:
Usage: minify index.js [options]
you point her at a file, she makes it tiny. iconic. now let's get into every single knob and dial, because there are a LOT and we are NOT skipping any π
π IO Options π
where the output actually goes, bestie.
--out-file,-oβ writes the output to one specific file you picked π«Ά--out-dir,-dβ writes the output into one specific directory instead π
π¦ Parser/Generator options π¦
this is the "how do we even read your code" part.
--sourceTypeβ tells her what mode the code should be parsed in. the valid options are"script"|"module"|"unambiguous"β those are the only ones, no cap.--commentsβ turns comments in the output on or off. and if you want something more specific than on/off, she says use the Node API instead β¨
π Transform Options π
the actual glow-up section. every single one:
--mangleβ context and scope aware variable renaming. she knows what she's doing π₯--simplifyβ simplifies code for minification by reducing statements into expressions--booleansβ transforms boolean literals into!0fortrueand!1forfalse--builtInsβ minify standard built-in objects--consecutiveAddsβ inlines consecutive property assignments, array pushes, etc.--deadcodeβ inlines bindings and tries to evaluate expressions.--evaluateβ tries to evaluate expressions and inline the result. deals with numbers and strings π’--flipComparisonsβ optimize code for repetition-based compression algorithms such as gzip--infinityβ minifyInfinityto1/0--memberExpressionsβ convert valid member expression property literals into plain identifiers--mergeVarsβ merge sibling variables into single variable declaration--numericLiteralsβ shortening of numeric literals via scientific notation--propertyLiteralsβ transform valid identifier property key literals into identifiers--regexpConstructorsβ changeRegExpconstructors into literals--removeConsoleβ removes allconsole.*calls π--removeDebuggerβ removes alldebuggerstatements--removeUndefinedβ removes rval's for variable assignments, return arguments from functions that evaluate toundefined--replaceβ replaces matching nodes in the tree with a given replacement node--simplifyComparisonsβ convert===and!==to==and!=if their types are inferred to be the same--typeConstructorsβ minify constructors to equivalent version--undefinedToVoidβ transformsundefinedintovoid 0
β Other Options β
the "please don't break my code" collection.
--keepFnNameβ preserve Function Name (useful for code depending onfn.name)--keepClassNameβ preserve Class Name (useful for code depending onc.name)--keepFnArgsβ don't remove unused fn arguments (useful for code depending onfn.length)--tdzβ Detect usages of variables in the Temporal Dead Zone π
π§ Nested Options π§
okay this one's lowkey the coolest part. if you wanna use nested options (that's plugin specific options, iykyk), you just use this pattern:
--pluginName.featureName
like, for example:
minify index.js --mangle.keepClassName --deadcode.keepFnArgs --outFile index.min.js
see how --mangle.keepClassName and --deadcode.keepFnArgs just stack up like that? chef's kiss π
β¨
just a heads up bestie: that example literally says --outFile in it, so write it exactly like that when you're copying her. don't come for me, i'm just the messenger π«Ά
π SEE ALSO π
<nope, no see also section in the original>
that's the whole page, bestie!! go forth and minify. this was babel-minify 0.5.2, from November 2022, and yes she still eats. mwah π ππ¦πΈ
π¦ where this page comes from
- debian bookworm: babel-minify 0.5.2+dfsg+~cs5.2.9-9 Β· MIT
- debian trixie: babel-minify 0.5.2+dfsg+~cs5.2.9-9 Β· MIT
- ubuntu noble: babel-minify 0.5.2+dfsg+~cs5.2.9-9 Β· MIT
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms