jacobobryant / biff

A Clojure web framework for solo developers.
https://biffweb.com
MIT License
877 stars 41 forks source link

running `bb dev` no css output #154

Closed schneiderlin closed 1 year ago

schneiderlin commented 1 year ago

I was following this tutorial: https://biffweb.com/docs/tutorial/landing-page/.

The tutorial screenshot shows that the landing page has CSS styling, but my local version does not.

When I try to access http://localhost:8080/css/main.css, it returns a "not found" error. I also cannot see any CSS file in the project directory.

Am I missing something?

jacobobryant commented 1 year ago

I just ran through the tutorial up to that point in case I introduced some kind of obvious bug recently (which has been known to happen...), but it's working for me, so perhaps some kind of environment issue. Are there any errors in the console? What happens if you run bin/tailwindcss -c resources/tailwind.config.js -i resources/tailwind.css -o target/resources/public/css/main.css ?

schneiderlin commented 1 year ago

The command bb dev runs without any errors:

> bb dev
[main] INFO com.eelchat - starting: com.biffweb$use_config@2e0cea03
[main] INFO com.eelchat - starting: com.biffweb$use_secrets@e9e7d7f
[main] INFO com.eelchat - starting: com.biffweb$use_xt@41c768d1
[main] INFO xtdb.tx - Started tx-ingester
[main] INFO com.biffweb.impl.xtdb - Indexed #:xtdb.api{:tx-time #inst "2023-05-08T11:27:02.603-00:00", :tx-id 0}
[main] INFO com.eelchat - starting: com.biffweb$use_queues@208b50e8
[main] INFO com.eelchat - starting: com.biffweb$use_tx_listener@444a633b
[main] INFO com.eelchat - starting: com.biffweb$use_jetty@6ff74f1b
[main] INFO org.eclipse.jetty.server.Server - jetty-10.0.7; built: 2021-10-06T19:34:02.766Z; git: da8a4553af9dd84080931fa0f8c678cd2d60f3d9; jvm 17.0.5+8-LTS
[main] INFO org.eclipse.jetty.server.handler.ContextHandler - Started o.e.j.s.ServletContextHandler@621d6441{/,null,AVAILABLE}
[main] INFO org.eclipse.jetty.server.AbstractConnector - Started ServerConnector@729b619a{HTTP/1.1, (http/1.1)}{0.0.0.0:8080}
[main] INFO org.eclipse.jetty.server.Server - Started Server@2d8105e0{STARTING}[10.0.7,sto=0] @9578ms
[main] INFO com.biffweb.impl.misc - Jetty running on <http://0.0.0.0:8080>
[main] INFO com.eelchat - starting: com.biffweb$use_chime@6d771bf5
[main] INFO com.eelchat - starting: com.biffweb$use_beholder@788648e8
[main] INFO com.eelchat - Go to <http://localhost:8080>
nREPL server started on port 7888 on host localhost - nrepl://localhost:7888
[qtp410511655-27] INFO com.biffweb.impl.middleware -   2ms 200 get  /css/main.css

However, when trying to manually run tailwindcss, a permission error occurs:

> bin/tailwindcss -c resources/tailwind.config.js -i resources/tailwind.css -o target/resources/public/css/main.css
zsh: permission denied: bin/tailwindcss

This problem may be due to running on a Mac M1, where the tailwindcss binary is incompatible. Installing a Macos-arm64 version of tailwindcss resolves the issue.

jacobobryant commented 1 year ago

Ah--the dev task tries to auto-detect the right build to install, but the method it used must not have been reliable. I've just pushed a commit to the dev branch that uses (System/getProperty "os.arch") instead (and also prints error messages correctly instead of letting them get swallowed as happened in your case). Can you run bb -e '(System/getProperty "os.arch")' and confirm that it returns something other than "amd64"?

schneiderlin commented 1 year ago

bb -e '(System/getProperty "os.arch")' returns "aarch64" in my machine

jacobobryant commented 1 year ago

Perfect. That commit should fix it for new projects then. I just merged it to master. No need to upgrade since you've already installed the correct binary, but if you did want to test it, you can set your biff dependency in tasks/deps.edn to {:git/url "https://github.com/jacobobryant/biff" :deps/root "tasks" :tag "v0.7.5" :sha "df935d8"}, delete/rename bin/tailwindcss, then run bb dev again. It should show a message like so (but with macos-arm64 instead of linux-x64):

Downloading the latest version of Tailwind CSS...

Auto-detected build: tailwindcss-linux-x64. If that's incorrect, set :biff.tasks/tailwind-file in config.edn.

After the download finishes, you can avoid downloading Tailwind again for future projects if you copy it to your path, e.g. by running:
  sudo cp bin/tailwindcss /usr/local/bin/