Skip to content

Instantly share code, notes, and snippets.

@bhauman
Last active April 27, 2016 18:03
Show Gist options
  • Star 3 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save bhauman/e90eb0b9523ab71eccc02af631ea3e1a to your computer and use it in GitHub Desktop.
Save bhauman/e90eb0b9523ab71eccc02af631ea3e1a to your computer and use it in GitHub Desktop.
common cljs build format ideas

A common build configuration format that all ClojureScript tools can consume

; A common shared Clojurescript build configuration file that can
; handle build tool specific concerns on a per build basis.
; in cljs-builds.edn
{
; id is a common concern among all tools
:dev {
; source-paths is common concern among all tools
:source-paths ["src" "dev"]
; build tool "build" specific concern
:figwheel { :on-jsload 'example.core/reload }
; build tool "build" specific concern
:cljbuild { :notify-command ["growl" "-f"] }
:compiler { :output-to "example.js"
:optimizations :none
... }}}
; Question: should it be standard require eval on read?
; global build tool concerns (like server-port) can be implemented as a build tool desires...
; but it would be cool say if figwheel had a figwheel.edn and cljsbuild read a cljsbuild.edn
; and doo had a doo.edn
; The figwheel.edn file could look as so
{:dev {:server-port 5000}
:prod false}
; Edn files would allow folks to trivially read configuration in from scripts
; another approach would be to have a gereral build config that doesn't have any
; build tool specific information in it
; I think I like this better
;cljs-builds.edn
; don't include any build tool specific information in this config
{:dev {:source-paths ["src" "dev"]
:compiler { :output-to "example.js"
:optimizations :none
... }}}
; in the project.clj the above could be entered like this
:cljs-builds { :dev {...}
:prod {...}}
; The above has some real advantages. We can write one library to read validate and thoroughly document this
; general configuration format. And then leave the tool specific validation to the individual tools.
; We then place "build" specific information in the build tool configuration wherever that may be
; figwheel.edn or in project.clj depending on mode of tool
{ :server-port 4555
:builds {:dev {:on-jsload 'example.core/reload}} }
;this is cleaner but maybe less clear when someone is trying to understand the config
; in a project.clj the above could be entered under the :figwheel key like so
:figwheel { :server-port 4555
:builds {} }
@bhauman
Copy link
Author

bhauman commented Apr 24, 2016

Obvious downside is that we are changing things up on folks, yet again. But if we could rally around one central build config in one place I think the change would be worth it especially if we can share read and validation.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment