Fork me on GitHub
#pedestal
<
2019-05-25
>
caleb.macdonaldblack06:05:17

How do I serve static files?

caleb.macdonaldblack06:05:25

I can't really find much online

souenzzo13:05:45

there is also file-path

souenzzo13:05:45

there is also file-path

ahmed1hsn05:05:55

Which of these is used to serve JavaScript script files like main.js?

souenzzo12:05:20

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

ahmed1hsn12:05:11

Bundle of thanks. It works. 🙂

ahmed1hsn12:05:04

When I change from ::http/file-path to ::http/resource-path it gives error again. What is difference here?

souenzzo13:05:24

::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" ...

souenzzo13:05:54

@caleb.macdonaldblack