haskellcabalhaskell-snap-framework

Add css and images to snap's cabal build?


When I build my snap project, it does not include any of my static resources or templates.

My project structure is as follows:

site.cabal
\src
\snaplets
      \heist
           *.tpl
\static
       \css
           *.css
       \images
           *.jpg

Currently, I am deploying my binary to the server separately from my static files (which I simply copy over).

Is there a better way to do this? Any help appreciated.


Solution

  • You can't embed your static files into the executable while still having things work as they should wrt the rest of snap.

    Also, in Windows there's a "resource system" in PE files which lets you embed resources, but on Linux/Unix there isn't. So, using external files is the only reliable way to ensure that they are reachable on every platform.

    Additionally, you might want to add or remove static files when users e.g. upload them, and that's not possible with embedded resources.