This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2019-05-25
Channels
- # announcements (1)
- # beginners (6)
- # calva (23)
- # cider (43)
- # clj-kondo (2)
- # cljdoc (22)
- # cljsrn (4)
- # clojure (35)
- # clojure-dev (1)
- # clojure-france (1)
- # clojure-italy (16)
- # clojure-uk (10)
- # clojurescript (1)
- # data-science (1)
- # emacs (6)
- # fulcro (5)
- # graalvm (4)
- # jobs-discuss (28)
- # off-topic (29)
- # pedestal (11)
- # planck (31)
- # prelude (2)
- # reitit (2)
- # vim (1)
How do I serve static files?
I can't really find much online
https://github.com/pedestal/pedestal/blob/master/service/src/io/pedestal/http.clj#L198
Which of these is used to serve JavaScript script files like main.js
?
I output my main.js
to somewhere like target/pubic/app/main.js
then I set ::http/file-path
to target/public
In the index.html
, you will import as <script src="/app/main.js">
Don't forget about ::http/mime-types mime/default-mime-types
Bundle of thanks. It works. 🙂
When I change from ::http/file-path
to ::http/resource-path
it gives error again. What is difference here?
::http/resource-path
needs to be something in your classpath. In :paths
from deps.edn
or :resource-paths
from project.clj
Example:
output main.js
in resource/public/app/main.js
resource
is in my classpath. I can test with (slurp (io/resource "public/app/main.js"))
should return my file
then I can use ::http/resource-path "public"
, my index with src="/app/main.js"
...