clojurescript

Caio Guedes 2024-10-17T13:13:40.895339Z

Hi o/, I'm having difficult to run my clojurescript app, it seems not able to find my index.html file... What I am trying to do is, generate the js files in public/js and my index.html is at the root of public folder, so when I try to run my script dev.sh to start the repl it always show me the default-index not my index file. (is I move my index.html to the root folder of the project, it works nicely) thinking-face

#!/usr/bin/env bash

clojure -M \
	--main cljs.main \
	--output-dir public/js \
	--output-to public/js/main.js \
	--verbose \
	--watch src \
	--compile todo.main \
	--repl

p-himik 2024-10-17T13:20:06.231809Z

Running a full-stack app with a CLJS REPL is something that should only be considered for development. When index.html is not found, you should see the default HTML page that says how to replace it. Namely: > To provide your own custom page, place an index.html file in the REPL launch directory

Caio Guedes 2024-10-17T13:30:13.486279Z

Right, then since I am running the repl in my root directory I will look for index there... So what I need then is tell the repl where is my :static-dir, im my case public also tell the compiler to change the :asset-path to js, as it already get public from --output-dir option...

Caio Guedes 2024-10-17T13:30:34.788539Z

#!/usr/bin/env bash

clojure -M \
	--main cljs.main \
	--output-dir public/js \
	--compile-opts '{:asset-path "js"}' \
	--verbose \
	--watch src \
	--repl-opts '{:static-dir "public"}'\
	--compile todo.main \
	--repl

Caio Guedes 2024-10-17T13:31:16.894649Z

Now I have it working 🥳

👍 1
p-himik 2024-10-17T13:31:51.622789Z

And in case you have a separate backend server, I would definitely recommend just serving all the relevant static files with it.

Caio Guedes 2024-10-17T13:35:48.547299Z

Great, I will keep in mind 😄 Thanks @p-himik o/

👍 1