Currently, I am writing a web application using Jester and would like to facilitate the deployment by bundling all static resources (CSS, HTML, JS).
What is the best way to do this in Nim ?
Currently, I am writing a web application using Jester and would like to facilitate the deployment by bundling all static resources (CSS, HTML, JS).
What is the best way to do this in Nim ?
The basic way is to use staticRead (aka slurp) to read a file at compile time and have it as a constant in your program. This can get tedious pretty fast since you would need to do this for each file manually, or generate a .nim
file with lots of these staticRead()
calls based on the current files of your directory before shipping and use those variables.
Another way might be to zip all files and have your program read/unpack them at runtime. The zip can be created without compression if you just want to use it to reduce file clutter on your deployment though you could experiment with fast compression settings which typically improve overall speed (IO is slow, so you program ends up spending less time waiting for the read to complete, and CPUs are really good at uncompressing today).
Combining the above you might want to embed the zip file into your binary and use it as a kind of embedded virtual filesystem.