Fork me on GitHub
#biff
<
2023-05-11
>
rcaze12:05:52

Hi, I also have a deployment-related question. How would I go about creating an uberjar with all the assets and the like? I'm struggling to find any docs or deconstruct the existing scripts/tasks to do that myself. Thanks!

Jacob O'Bryant16:05:58

There's no code or docs for it, but at a high level you could use tools.build to create the jar, and during the build phase, generate the html files (https://github.com/jacobobryant/biff/blob/master/example/src/com/example.clj#L33) and the css file (https://github.com/jacobobryant/biff/blob/master/tasks/src/com/biffweb/tasks.clj#L129)

rcaze16:05:17

Got it, I'll try to figure it out. Thanks!

👌 1
rcaze12:05:27

OK, took a moment but I figured it out. Just a tip if anyone reads this and has trouble getting it to work: once you get all the assets to compile and get included in the jar, you still need to make a change in the base`` function in your ui.clj``. I'm not an expert, but I assume the css-path`` function that's there by default is checking the filesystem for the CSS file, essentially trying to get it from outside the JAR. So you need to hard-code the path to another file that you will use in production, or add some conditional logic to make sure css-path is only run in dev.

Jacob O'Bryant16:05:53

ah yes, I believe that's because io/file doesn't work when you pass it a resource that's inside a jar. You can probably get by with just replacing the (css-path) call with "/css/main.css". I added that function because I was making frequent updates to the production css file due to the develop-in-prod workflow; if you're deploying with jars then presumably it'd be less of an issue. 🤷 . if you've got developer tools open with "disable cache" enabled then you should be fine in dev. Wouldn't hurt to figure out a way to make that fn work whether the css file is in a jar or not.

👍 4