How to minify the javascript output?

205 views
Skip to first unread message

HaxeIsGreat

unread,
Oct 12, 2017, 8:31:40 AM10/12/17
to Haxe
Haxe doesn't seem to include a minifier.
So I need to minify it later with some other tool, but I cannot make it to work because of the source maps.
If I generate the source maps from the haxe tool, how can I pass them on to standard minifier?

I tried to use the uglifyjs --in-source-map attribute but with no success, these are the commands:

haxe -lib pixijs -cp app/haxe/src -main Main -js app/js/haxe.js -D js-source-map
uglifyjs app/js/haxe.js --in-source-map app/js/haxe.js.map -source-map url=js/haxe.min.js.map -o app/js/haxe.min.js -c

HaxeIsGreat

unread,
Oct 12, 2017, 8:32:54 AM10/12/17
to Haxe
in essence, once I load everything in chrome, the sources are gone... chrome doesn't seem to be able to put the dots together.

Philippe Elsass

unread,
Oct 12, 2017, 9:39:37 AM10/12/17
to Haxe
Here's something that works with UglifyJS2:
uglifyjs2 test.js --in-source-map test.js.map --source-map-root '' --source-map test.min.js.map -o test.min.js -c

I had to clear the source-map-root to get the map to function.

Philippe


--
To post to this group haxe...@googlegroups.com
http://groups.google.com/group/haxelang?hl=en
---
You received this message because you are subscribed to the Google Groups "Haxe" group.
For more options, visit https://groups.google.com/d/optout.



--
Philippe

HaxeIsGreat

unread,
Oct 13, 2017, 5:50:15 AM10/13/17
to Haxe
I tried the same here and it doesn't show the .hx files in Chrome.
Something goes wrong with uglifyjs.

Philippe Elsass

unread,
Oct 13, 2017, 6:42:21 AM10/13/17
to Haxe
Try adding -D source-map-content to include the hx code in the .map file.

HaxeIsGreat

unread,
Oct 13, 2017, 7:51:06 AM10/13/17
to Haxe
Doesn't make any difference, this is the comman I tried:

uglifyjs2 app/js/haxe.js --in-source-map app/js/haxe.js.map --source-map-root '' --source-map build/js/haxe.min.js.map -D source-map-content -o build/js/haxe.min.js -cm

I don't see the sources being added to the .map file, is that feature working? That'd be good.

Philippe Elsass

unread,
Oct 13, 2017, 8:15:41 AM10/13/17
to Haxe
That's a Haxe compiler flag :D

HaxeIsGreat

unread,
Oct 13, 2017, 8:30:38 AM10/13/17
to Haxe
Ops sorry.

These are the 2 commands I run:

haxe -lib pixijs -cp app/haxe/src -main Starter -js app/js/haxe.js -D js-source-map -D source-map-content
uglifyjs2 app/js/haxe.js --in-source-map app/js/haxe.js.map --source-map-root '' --source-map build/js/haxe.min.js.map -o build/js/haxe.min.js -c

Still i cannot see .hx files inside Chrome.
The source is added inside have.js.map produced by haxe, but it gets filtered by uglifyjs2. There is no source content in the final haxe.min.js.map
Reply all
Reply to author
Forward
0 new messages