Where to specify clojurescript compiler options



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.

I’m following the layout explained in the quick start guide: https://clojurescript.org/guides/quick-start, that is I have a deps.edn file and src folder.


Try :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.

Maybe you need something like https://clojurescript.org/guides/code-splitting#_release_builds ?

I would still recommend learning shadow-cljs as your first cljs compiler though… There are some mininal projects based on it.


It’s --compile-opts?

=>> 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


Yes --compile-options, I wrote from memory.


Yes, thanks. It seems there is more than one way to achieve this.

I would still recommend learning shadow-cljs as your first cljs compiler though

Why? and why does cljs has so many compilers. Can you please explain or point me to some reference.


Try this ClojureScript for web development - where to start? (AKA Little Printf [1])

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.