How to Bundle Resources

This guide will show you how to configure Dune to generate modules with string resources from other files in your project.

Folder Structure

$ tree src
src
└── lib
    └── my_lib
        ├── dune
        └── resources
            └── site.css

Dune Configuration

See progn and with-<outputs>-to.

(rule
 (with-stdout-to
  css.ml
  (progn
   (echo "let css = {|")
   (cat resources/site.css)
   (echo "|}"))))

Using the Bundled Resource

let () = Printf.printf "%s" Css.css