1

I need to add leaningen project

my-compojure/src/dist/output.css

from tailwind to my compojure project. Where should I put it?

After starting the server, I am naively calling

localhost:3000/dist/output.css

But that does not work.

Does anybody know, how I can add these static files in compojure?

1

1 Answer 1

0

You need to serve the static files from your server. When using Leiningen you can place the file in the resources/public folder in the root. Ensure the project.clj points to the resource folder with :resource-paths ["resources"]. Then serve the resources folder using Compojure:

(:require [ring.middleware.resource :refer [wrap-resource]])

(def app
  (wrap-resource approutes "public")) ; serve static files from "resources/public"

(def server (run-jetty #'app {:join? false, :port 3000}))

See Serve static resources using Clojure's Ring for a more elaborate example.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.