Mistre83 Mistre83 - 6 months ago 27
Node.js Question

Babel - Transpile code and minify it

Right now in my Node application i use Babel to transpile ES6 syntax with this command:

./node_modules/.bin/babel src/ -d bin/


With this, babel compile my code and this can be executed from
node


Because my application will be installed in different machines, i would like to "minify" it, or create a sort of release where source code is not accessible.

I have many directories in
src/
and this will maintain the same order in
bin/
, this will be ok, i just would like that the "binary" code produced is minified or in some way "crypted" and not human redeable.

I've search a lot of it and (if i have understand well)
babel
dont have this options.

How i can do that ?

Answer

Do you mean compact option? ( default is "auto" )

Do not include superfluous whitespace characters and line terminators. When set > to "auto" compact is set to true on input sizes of >100KB.

But in fact it's not task for babel. You can use additional tool ( like uglifyjs ) for minifying / obfuscation code