-
Notifications
You must be signed in to change notification settings - Fork 151
Compilation profiles
You can share common parameters of ClojureScript compiler by placing them in a leiningen profile. Note that while cljsbuild accepts 2 forms of build sequences [{:id "a-build-id" ...}]
and [:a-build-id {...}]
to override build parameters you should use map form. If you specify builds as list then builds from mix-in profiles will be added to resulting profile.
First example - mix-in profile with common parameters for "main" build:
(defproject ......
:profiles
{:cljs-shared ; Common parameters are in this profile
{:cljsbuild
{:source-paths ["src-cljs"]
:compiler {:asset-path "/js"}}}
:dev
[:cljs-shared ; Mix-in common parameters
{:cljsbuild ; Development parameters
{:optimizations :whitespace}}]
:uberjar
[:cljs-shared ; Mix-in common parameters
{:cljsbuild ; Release parameters
{:optimizations :advanced}}]
})
Although "whitespace" optimization level is sufficiently fast for development, one may want to compile without optimizations at all. Setting optimization parameters to "none" generates JavaScript file that contains only "require" calls and top-level code. Files layout in this case differ from one of other optimization options (whitespace, simple, advanced) which generate single file.
To have same entry point file with "none" optimizations as in other cases one need to specify [:compiler :main]
option. To ensure that cross references ("require" calls) work as expected output files should be written appropriately. Configuration example:
(defproject .....
:resource-paths ["resources" "target/resources"]
:cljsbuild
{:source-paths ["src-cljs"]
:compiler {
:optimizations :none
:asset-path "/js"
:main "a-project.main" ; Cljs "main" namespace
:output-dir "target/resources/public/js" ; Root of served javascript resources
}})