{
"$type": "site.standard.document",
"canonicalUrl": "https://numergent.com/2015-07/cljs-build-configuration-tip-prefer-maps-over-a-vector.html",
"path": "/2015-07/cljs-build-configuration-tip-prefer-maps-over-a-vector.html",
"publishedAt": "2015-07-27T06:14:16.000Z",
"site": "at://did:plc:cf6futaebyc2k4wgzsr4v42k/site.standard.publication/3mp2ewx43js2g",
"tags": [
"clojure",
"clojurescript",
"lein"
],
"textContent": "If you look at the lein cljs-build sample project, you'll see that it states:\n\n\t; The :builds option should be set to a sequence of maps. Each\n\t; map will be treated as a separate, independent, ClojureScript\n\t; compiler configuration.\n\nIf you look at the example right below that description, you'll see that it is actually set as a map of configuration profiles with the configuration name as the key. So what gives?\n\n\n\nBoth options work, since the convert-builds-map function on cljs-build ends up converting :builds map to a vector if it instead receives a map. Should you just save this step and do it as a vector yourself?\n\nTurns out there is an advantage to having the :builds as a straight map with the profile as the key, than a vector of maps.\n\nProfiles on lein are merged. If globally you declare your :builds as a vector of maps, instead of a map, then when you try to alter just one value on a profile you end up with one more build configuration. If instead :builds is a map indexed by the build id, then lein will just merge both configuration values.\n\nTo give an example, suppose you have the following configuration.\n\n\t:cljsbuild\n\t {:builds\n\t {:app\n\t {:source-paths [\"src/cljs\"]\n\t :compiler {:other :options-here}\n\t }}}\n\nLater, on your :profiles section you could change the :source-paths, to do:\n\n\t:test \n\t {:cljsbuild\n\t {:builds\n\t {:app\n\t {:source-paths [\"src/cljs\" \"src/test-cljs/\"]\n\t }}}}\n\nThis would work just fine, with the :source-paths property being merged into the base :cljsbuild configuration.",
"title": "cljs-build configuration tip: prefer maps over a vector"
}