Wednesday 15 January 2020

How to uglify ES6 javascript with Flask?

I'm searching a Flask-Assets filter that allows me to uglify javascript and support ES6 syntax. I tried to use uglifyjs-es binary instead of uglifyjs but I can't figure out how to configure my filter to use the uglifyjs-es binary.

I've this:

my_app_js = Bundle(
    'js/MyApp.js',
    filters='uglifyjs',
    output='my_app_js.js'
)

From the Webassets documentation :

UglifyJS is an external tool written for NodeJS; this filter assumes that the uglifyjs executable is in the path. Otherwise, you may define a UGLIFYJS_BIN setting

Maybe the solution is there but I can't figure out where and how to change that UGLIFYJS_BIN setting, any idea ?

Also, I read here that uglifyjs-es project isn't maintenained anymore. terser seems to be the alternative, but could it be used as a filter too ?

Edit

If you know a good alternative to uglifyjs-es with a code example, you win a bounty ;)



from How to uglify ES6 javascript with Flask?

No comments:

Post a Comment