I want to serve files from node_modules
directory in project root.
so for example I added to my page this:
[:link {:href "/font-awesome/css/font-awesome.css" :rel "stylesheet" :type "text/css"}]
now I need to tell compojure to serve statically anything that's in node_modules
directory, and I can't find a way.
It works if I move node_modules to resources/public
dir, but I don't want that. I need to find a way to serve files from anywhere in the project directory (in this case from ./node_modules
)
I tried adding :resource-paths ["node_modules"]
to profiles.clj
,
I tried (compojure.route/resources "node_modules" {:root "../.." })
, that still didn't work.
This is what I did:
added :resource-paths ["node_modules"]
to project.clj - take a look at leiningen's sample
and then (compojure.route/resources "/" {:root "" })
. Seems it worked.
upd : this apparently exposed things that should not be exposed. eg it's possible now to download project.clj
by navigating to it in the browser. not good.
upd 2 : (compojure.route/files "/" {:root "node_modules" })
this time it's right.
Symlink the file(s) or use @import
in something in your static files to include your font-awesome css. I haven't tried this but you might also either create a project_root/special_css folder and add it to the css-dirs
in project.clj or try adding the special file itself to the vector (not sure if that would work).
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.