Adding static files to Yesod

In a Yesod app the files in the static folder can be accessed as a variable composed by the folder structure and the name of the file. For example, a file in static/css/main.css will be css_main_css.

If the static folder is modified, the StaticFiles.hs file needs to be recompiled for Yesod to catch up with the changes.

Another solution is to add -fforce-recomp to the ghc-options in the package.yaml file:

  source-dirs: src
  - condition: (flag(dev)) || (flag(library-only))
      - -Wall
      - -fwarn-tabs
      - -O0
      - -fforce-recomp
      cpp-options: -DDEVELOPMENT
      - -Wall
      - -fwarn-tabs
      - -O2

Related Posts

Resizing and moving windows in Doom Emacs

Setting up TabNine on Doom Emacs

The correct docker-compose setup for Wordpress and Nginx

Adding a newline after a comment block in Doom Emacs

PureScript Date and Time guide

Adding live css and js reload to Yesod

A quick overview of Purescript package managers as of October 2018

Optional elements and properties in Halogen

Simple AJAX in Purescript

Automatically adding (or removing) a prefix to a record labels in Purescript