I’m trying to port client side JavaScript code to ClojureScript. I want to change the :asset-path, as mentioned here: https://clojurescript.org/reference/compiler-options, but I cannot find where to specify the compiler options.
This seems to be shadow-cljs specific. Since I’m just starting out, I want to keep use of external tools to be minimal.
From what I have read till now, I think I’ll need a project.clj file.
No need for a project.clj. The cljs.main accept a -co (for --compiler-options) option where you specify the name of an .edn file containing all compiler options. Read more using -h (for --help).
I was guessing it’s using the name option name. :compiler-options is not invented by shadow-cljs. It was used in boot-cljs as well. However it turned out not the name in CLI tools.
=>> clj -m cljs.main --help
Usage: java -cp cljs.jar cljs.main [init-opt*] [main-opt] [arg*]
With no options or args, runs an interactive Read-Eval-Print Loop
init options:
-co, --compile-opts edn Options to configure the build, can be an EDN
string or system-dependent path-separated list of
EDN files / classpath resources. Options will be
merged left to right.
-d, --output-dir path Set the output directory to use. If supplied,
cljsc_opts.edn in that directory will be used to
set ClojureScript compiler options
Best compilers today I think are figwheel-main and shadow-cljs. However if you are new to Clojure, shadow-cljs would be a better option to start with. It has better support for npm ecosystem and brings quite some features and experiences from Webpack.
There is only one compiler: ClojureScript itself. All the other stuff like shadow-cljs and figwheel is about build tooling. They take what the ClojureScript compiler produces and organize/bundle it to do interesting stuff like live reload. These tools just provide enhanced build features, just like you’d combine TypeScript with webpack.