luminus-framework/examples

Where are the assets?

endrebak opened this issue · 3 comments

In the html page you refer to assets such as

    {% style "/assets/bulma/css/bulma.min.css" %}
    {% style "/assets/material-icons/css/material-icons.min.css" %}
    {% style "/css/screen.css" %}

However, I cannot find any assets path. Where are they?

ls **.css
resources/public/css/screen.css
# missing "/assets/material-icons/css/material-icons.min.css" and "/assets/bulma/css/bulma.min.css"

I get these error messages in the js console:

Refused to apply style from 'http://localhost:50400/assets/bulma/css/bulma.min.css' because its MIME type ('text/html') is not a supported stylesheet MIME type, and strict MIME checking is enabled.

2(index):1 Refused to apply style from 'http://localhost:50400/assets/material-icons/css/material-icons.min.css' because its MIME type ('text/html') is not a supported stylesheet MIME type, and strict MIME checking is enabled.

The problem happens in this example: https://github.com/endrebak/re-make/blob/master/src/clj/re_make/core.clj#L83

Normally, luminus produces code like:

(defn home-page [request]
  (layout/render request "home.html"))

(defn home-routes []
  [""
   {:middleware [middleware/wrap-csrf
                 middleware/wrap-formats]}
   ["/" {:get home-page}]
   ["/docs" {:get (fn [_]
                    (-> (response/ok (-> "docs/docs.md" io/resource slurp))
                        (response/header "Content-Type" "text/plain; charset=utf-8")))}]])

But I am trying to get the lein new luminus <name> +re-frame +shadow-cljs +immutant to work with the official sente-example at https://github.com/ptaoussanis/sente/tree/master/example-project

so my code looks like this:

(defn home-page [request]
  (layout/render request "home.html"))

(defroutes ring-routes
  (GET  "/"      ring-req (home-page ring-req))
  (GET  "/chsk"  ring-req (ring-ajax-get-or-ws-handshake ring-req))
  (POST "/chsk"  ring-req (ring-ajax-post                ring-req))
  (POST "/login" ring-req (login-handler                 ring-req))
  (route/resources "/") ; Static files, notably public/main.js (our cljs target)
  (route/not-found "<h1>Page not found</h1>"))

I have only changed the routes, yet this is enough to make the css not load. I have bought your book, but cannot find anything in it about how the assets are gotten even though they do not seem to be part of the project.

  1. Do you understand and have the opportunity to explain what is happening? Thanks.

  2. A feature request would be to add a +sente to the luminus template :)

Hi, the assets come from a dependency jar from webjars, and they're loaded using this middleware. One thing to double check would be whether the middleware is being used, if it's not then that would prevent the assets from loading. This example might be a good one to start from to see what's different from yours.

And +sente option sounds like a good idea, I'll take a look when I get a chance.

Thanks! When I know the name of what is missing I can start read up on the issue. Thanks again :)

No prob 👍