When I compile my Snap webapp (to deploy it to production server), it comes out to 19MB! What gives? Is this normal? Am I doing something wrong?
My site only has 3 static pages, basically snap's init project.
When I compile my Snap webapp (to deploy it to production server), it comes out to 19MB! What gives? Is this normal? Am I doing something wrong?
My site only has 3 static pages, basically snap's init project.
I guess Snap pulls a lot of dependencies. One solution to this problem, which unfortunately affects the (initial) compilation time is to install libraries your project depend on with --split-objs option. That will generate a ton of different object but will make the final executable a lot smaller, like 2-4 times smaller.
$ cabal install --enable-split-objs
If you already have the libraries installed you will need to remove them first, install a fresh GHC or use sandbox with it's own package set.
You should also use strip
command (cabal does this automatically in some cases).
Additionally you may consider using upx
for compressing executables and finally rsync
to upload minimally different executable to the server.
Using shared libraries (cabal install --enable-shared
) may or may not help here: I didn't experiment with that option.