Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Newer
Older
100644 232 lines (175 sloc) 7.679 kb
e0219ff @emezeske Initial commit of lein-cljsbuild.
authored
1 # lein-cljsbuild
2
771f2bd @emezeske Breaking down the giant monolithic README.
authored
3 This is a Leiningen plugin that makes it quick and easy to automatically compile
c3debe3 @emezeske Fix some odd wording.
authored
4 your ClojureScript code into Javascript whenever you modify it. It's simple
771f2bd @emezeske Breaking down the giant monolithic README.
authored
5 to install and allows you to configure the ClojureScript compiler from within your
6 `project.clj` file.
cb80cbc @emezeske Preparing for release.
authored
7
771f2bd @emezeske Breaking down the giant monolithic README.
authored
8 Beyond basic compiler support, lein-cljsbuild can optionally help with a few other things:
2e46cd7 @emezeske Try to make bullet points work...?
authored
9
4ef527a @emezeske Bump the project version.
authored
10 * [Launching REPLs for interactive development] (https://github.com/emezeske/lein-cljsbuild/blob/0.2.7/doc/REPL.md)
11 * [Launching ClojureScript tests] (https://github.com/emezeske/lein-cljsbuild/blob/0.2.7/doc/TESTING.md)
12 * [Sharing code between Clojure and ClojureScript] (https://github.com/emezeske/lein-cljsbuild/blob/0.2.7/doc/CROSSOVERS.md)
91e8506 @emezeske Adding crossover support and examples.
authored
13
4ef527a @emezeske Bump the project version.
authored
14 The latest version of lein-cljsbuild is `0.2.7`.
15 [See the release notes here.](https://github.com/emezeske/lein-cljsbuild/blob/0.2.7/doc/RELEASE-NOTES.md)
09ab979 @emezeske Link to the release notes.
authored
16
c391aaf @emezeske Doc updates. Fixes #20.
authored
17 ## Requirements
18
3b24e9f @emezeske Try a different link format.
authored
19 The lein-cljsbuild plugin works with
20 [Leiningen] (https://github.com/technomancy/leiningen/blob/master/README.md)
1091b21 @emezeske Remove old lein 1.6 instructions.
authored
21 version `1.7.0` or higher.
e0219ff @emezeske Initial commit of lein-cljsbuild.
authored
22
c391aaf @emezeske Doc updates. Fixes #20.
authored
23 ## Installation
cb80cbc @emezeske Preparing for release.
authored
24
1091b21 @emezeske Remove old lein 1.6 instructions.
authored
25 You can install the plugin by adding lein-cljsbuild to your `project.clj`
26 file in the `:plugins` section:
cb80cbc @emezeske Preparing for release.
authored
27
d428aad @emezeske Mark code as "clj" instead of "clojure".
authored
28 ```clj
0b2edaa @emezeske Initial changes for Leiningen 1.7 compatibility.
authored
29 ; Using Leiningen 1.7.0 or newer:
91e8506 @emezeske Adding crossover support and examples.
authored
30 (defproject lein-cljsbuild-example "1.2.3"
4ef527a @emezeske Bump the project version.
authored
31 :plugins [[lein-cljsbuild "0.2.7"]])
0b2edaa @emezeske Initial changes for Leiningen 1.7 compatibility.
authored
32 ```
33
1091b21 @emezeske Remove old lein 1.6 instructions.
authored
34 And then running the following command to download it:
cb80cbc @emezeske Preparing for release.
authored
35
36 $ lein deps
37
91e8506 @emezeske Adding crossover support and examples.
authored
38 ## Just Give Me a Damned Example Already!
39
771f2bd @emezeske Breaking down the giant monolithic README.
authored
40 See the
4ef527a @emezeske Bump the project version.
authored
41 [example-projects] (https://github.com/emezeske/lein-cljsbuild/blob/0.2.7/example-projects)
771f2bd @emezeske Breaking down the giant monolithic README.
authored
42 directory for a couple of simple examples of how to use lein-cljsbuild. The
4ef527a @emezeske Bump the project version.
authored
43 [simple project] (https://github.com/emezeske/lein-cljsbuild/blob/0.2.7/example-projects/simple)
771f2bd @emezeske Breaking down the giant monolithic README.
authored
44 shows a dead-simple "compile only" configuration, which is a good place to start. The
4ef527a @emezeske Bump the project version.
authored
45 [advanced project] (https://github.com/emezeske/lein-cljsbuild/blob/0.2.7/example-projects/advanced)
771f2bd @emezeske Breaking down the giant monolithic README.
authored
46 contains examples of how to use the extended features of the plugin.
91e8506 @emezeske Adding crossover support and examples.
authored
47
771f2bd @emezeske Breaking down the giant monolithic README.
authored
48 Also, see the
4ef527a @emezeske Bump the project version.
authored
49 [sample.project.clj] (https://github.com/emezeske/lein-cljsbuild/blob/0.2.7/sample.project.clj)
771f2bd @emezeske Breaking down the giant monolithic README.
authored
50 file for an exhaustive list of all options supported by lein-cljsbuild.
31039ba @emezeske Add a note about example.project.js.
authored
51
6c54184 @emezeske Document the new parallel build feature.
authored
52 ## Basic Configuration
cb80cbc @emezeske Preparing for release.
authored
53
54 The lein-cljsbuild configuration is specified under the `:cljsbuild` section
91e8506 @emezeske Adding crossover support and examples.
authored
55 of your `project.clj` file. A simple project might look like this:
cb80cbc @emezeske Preparing for release.
authored
56
d428aad @emezeske Mark code as "clj" instead of "clojure".
authored
57 ```clj
91e8506 @emezeske Adding crossover support and examples.
authored
58 (defproject lein-cljsbuild-example "1.2.3"
4ef527a @emezeske Bump the project version.
authored
59 :plugins [[lein-cljsbuild "0.2.7"]]
593631b @emezeske Try to appease github's markdown flavor.
authored
60 :cljsbuild {
2ec547a @emezeske Massive documentation update for REPL stuff.
authored
61 :builds [{
62 ; The path to the top-level ClojureScript source directory:
63 :source-path "src-cljs"
64 ; The standard ClojureScript compiler options:
65 ; (See the ClojureScript compiler documentation for details.)
66 :compiler {
67 :output-to "war/javascripts/main.js" ; default: main.js in current directory
68 :optimizations :whitespace
69 :pretty-print true}}]})
593631b @emezeske Try to appease github's markdown flavor.
authored
70 ```
e0219ff @emezeske Initial commit of lein-cljsbuild.
authored
71
771f2bd @emezeske Breaking down the giant monolithic README.
authored
72 For an exhaustive list of the configuration options supported by lein-cljsbuild, see the
4ef527a @emezeske Bump the project version.
authored
73 [sample.project.clj] (https://github.com/emezeske/lein-cljsbuild/blob/0.2.7/sample.project.clj)
771f2bd @emezeske Breaking down the giant monolithic README.
authored
74 file.
c391aaf @emezeske Doc updates. Fixes #20.
authored
75
771f2bd @emezeske Breaking down the giant monolithic README.
authored
76 ## Basic Usage
e0219ff @emezeske Initial commit of lein-cljsbuild.
authored
77
cb80cbc @emezeske Preparing for release.
authored
78 Once the plugin is installed, you can build the ClojureScript once:
79
80 $ lein cljsbuild once
81
82 Or you can have lein-cljsbuild watch your source files for changes and
83 automatically rebuild them. This is recommended for development, as it
84 avoids the time-consuming JVM startup for each build:
85
86 $ lein cljsbuild auto
e0219ff @emezeske Initial commit of lein-cljsbuild.
authored
87
d40c3a9 @emezeske Add a "cljsbuild clean" task, and hook into "clean".
authored
88 To delete all of the JavaScript and ClojureScript files that lein-cljsbuild
89 automatically generated during compilation, run:
90
91 $ lein cljsbuild clean
92
3138773 @emezeske Add a note about sample.project.clj.
authored
93 ## Hooks
94
461d19a @emezeske Add some more documentation TODOs.
authored
95 Some common lein-cljsbuild tasks can hook into the main Leiningen tasks
96 to enable ClojureScript support in each of them. The following tasks are
97 supported:
98
99 $ lein compile
100 $ lein clean
101 $ lein test
102 $ lein jar
103
104 To enable ClojureScript support for these tasks, add the following entry to
105 your project configuration:
3138773 @emezeske Add a note about sample.project.clj.
authored
106
d428aad @emezeske Mark code as "clj" instead of "clojure".
authored
107 ```clj
3138773 @emezeske Add a note about sample.project.clj.
authored
108 :hooks [leiningen.cljsbuild]
109 ```
110
461d19a @emezeske Add some more documentation TODOs.
authored
111 Note that by default the `lein jar` task does *not* package your ClojureScript
112 code in the JAR file. This feature needs to be explicitly enabled by adding
113 the following entry to each of the `:builds` that you want included in the
114 JAR file.
3138773 @emezeske Add a note about sample.project.clj.
authored
115
d428aad @emezeske Mark code as "clj" instead of "clojure".
authored
116 ```clj
3138773 @emezeske Add a note about sample.project.clj.
authored
117 :jar true
118 ```
119
9d8d3f1 @emezeske Update the crossover documentation.
authored
120 If you are using the
4ef527a @emezeske Bump the project version.
authored
121 [crossovers] (https://github.com/emezeske/lein-cljsbuild/blob/0.2.7/doc/CROSSOVERS.md)
9d8d3f1 @emezeske Update the crossover documentation.
authored
122 feature, and want the `:crossover-path` included in the JAR file, add this entry to your
123 top-level `:cljsbuild` configuration:
124
125 ```clj
126 :crossover-jar true
127 ```
128
6c54184 @emezeske Document the new parallel build feature.
authored
129 ## Multiple Build Configurations
130
2ec547a @emezeske Massive documentation update for REPL stuff.
authored
131 If the `:builds` sequence contains more than one map lein-cljsbuild
132 will treat each map as a separate ClojureScript compiler configuration,
133 and will build all of them in parallel:
6c54184 @emezeske Document the new parallel build feature.
authored
134
d428aad @emezeske Mark code as "clj" instead of "clojure".
authored
135 ```clj
6c54184 @emezeske Document the new parallel build feature.
authored
136 (defproject lein-cljsbuild-example "1.2.3"
4ef527a @emezeske Bump the project version.
authored
137 :plugins [[lein-cljsbuild "0.2.7"]]
2ec547a @emezeske Massive documentation update for REPL stuff.
authored
138 :cljsbuild {
139 :builds [
140 {:source-path "src-cljs-main"
141 :compiler {:output-to "main.js"}}
142 {:source-path "src-cljs-other"
143 :compiler {:output-to "other.js"}}}])
6c54184 @emezeske Document the new parallel build feature.
authored
144 ```
145
146 This is extremely convenient for doing library development in ClojureScript.
147 This allows cljsbuild to compile in all four optimization levels at once, for
148 easier testing, or to compile a test suite alongside the library code.
149
ca7937a @fhd Make it possible to specify builds as a map
fhd authored
150 You can optionally assign an ID to a build configuration and build
151 only that one:
6eb0295 @fhd Make it possible to invoke specific build configurations
fhd authored
152
153 ```clj
154 (defproject lein-cljsbuild-example "1.2.3"
4ef527a @emezeske Bump the project version.
authored
155 :plugins [[lein-cljsbuild "0.2.7"]]
6eb0295 @fhd Make it possible to invoke specific build configurations
fhd authored
156 :cljsbuild {
157 :builds [
ca7937a @fhd Make it possible to specify builds as a map
fhd authored
158 {:source-path "src-cljs-main"
6eb0295 @fhd Make it possible to invoke specific build configurations
fhd authored
159 :compiler {:output-to "main.js"}}
160 {:id "other"
161 :source-path "src-cljs-other"
162 :compiler {:output-to "other.js"}}}])
163 ```
164
ca7937a @fhd Make it possible to specify builds as a map
fhd authored
165 $ lein cljsbuild auto other
166
167 If you want IDs for all of your build configurations, you can specify
168 them as a map instead of a vector:
169
170 ```clj
171 (defproject lein-cljsbuild-example "1.2.3"
4ef527a @emezeske Bump the project version.
authored
172 :plugins [[lein-cljsbuild "0.2.7"]]
ca7937a @fhd Make it possible to specify builds as a map
fhd authored
173 :cljsbuild {
174 :builds {
175 :main
176 {:source-path "src-cljs-main"
177 :compiler {:output-to "main.js"}}
178 :other
179 {:source-path "src-cljs-other"
180 :compiler {:output-to "other.js"}}}})
181 ```
182
183 You can also build multiple configurations at once:
184
185 $ lein cljsbuild auto main other
6eb0295 @fhd Make it possible to invoke specific build configurations
fhd authored
186
771f2bd @emezeske Breaking down the giant monolithic README.
authored
187 See the
4ef527a @emezeske Bump the project version.
authored
188 [example-projects/advanced] (https://github.com/emezeske/lein-cljsbuild/blob/0.2.7/example-projects/advanced)
771f2bd @emezeske Breaking down the giant monolithic README.
authored
189 directory for a working example of a project that uses this feature.
6c54184 @emezeske Document the new parallel build feature.
authored
190
2ec547a @emezeske Massive documentation update for REPL stuff.
authored
191 ## REPL Support
192
193 Lein-cljsbuild has built-in support for launching ClojureScript REPLs in a variety
771f2bd @emezeske Breaking down the giant monolithic README.
authored
194 of ways. See the
4ef527a @emezeske Bump the project version.
authored
195 [REPL documentation] (https://github.com/emezeske/lein-cljsbuild/blob/0.2.7/doc/REPL.md)
771f2bd @emezeske Breaking down the giant monolithic README.
authored
196 for more details.
2ec547a @emezeske Massive documentation update for REPL stuff.
authored
197
461d19a @emezeske Add some more documentation TODOs.
authored
198 ## Testing Support
199
61a9a0d @emezeske Start filling in the TESTING documentation.
authored
200 Lein-cljsbuild has built-in support for running external ClojureScript test processes. See the
4ef527a @emezeske Bump the project version.
authored
201 [testing documentation] (https://github.com/emezeske/lein-cljsbuild/blob/0.2.7/doc/TESTING.md)
461d19a @emezeske Add some more documentation TODOs.
authored
202 for more details.
203
71606e2 @emezeske Tiny formatting fix.
authored
204 ## Sharing Code Between Clojure and ClojureScript
91e8506 @emezeske Adding crossover support and examples.
authored
205
206 Sharing code with lein-cljsbuild is accomplished via the configuration
771f2bd @emezeske Breaking down the giant monolithic README.
authored
207 of "crossovers". See the
4ef527a @emezeske Bump the project version.
authored
208 [crossovers documentation] (https://github.com/emezeske/lein-cljsbuild/blob/0.2.7/doc/CROSSOVERS.md)
771f2bd @emezeske Breaking down the giant monolithic README.
authored
209 for more details.
91e8506 @emezeske Adding crossover support and examples.
authored
210
e0219ff @emezeske Initial commit of lein-cljsbuild.
authored
211 ## License
212
460cada @kumarshantanu fix typo in documentation
kumarshantanu authored
213 Source Copyright © Evan Mezeske, 2011-2012.
cb80cbc @emezeske Preparing for release.
authored
214 Released under the Eclipse Public License - v 1.0.
215 See the file COPYING.
27ded34 @emezeske Add a contributors section.
authored
216
217 ## Contributors
218
219 * Evan Mezeske **(Author)** (evan@mezeske.com)
220 * Shantanu Kumar (kumar.shantanu@gmail.com)
7604367 @emezeske Add Luke VanderHart to the contributor list.
authored
221 * Luke VanderHart (http://github.com/levand)
992a91b @emezeske Add Phil Hagelberg to the contributors list.
authored
222 * Phil Hagelberg (phil@hagelb.org)
12dafc8 @emezeske Add Daniel E. Renfer to the contributors list.
authored
223 * Daniel E. Renfer (duck@kronkltd.net)
6257348 @emezeske Add Daniel Harper to the contributors list.
authored
224 * Daniel Harper (http://djhworld.github.com)
6b8adcd @emezeske Add Philip Kamenarsky to the contributors list.
authored
225 * Philip Kamenarsky (http://github.com/pkamenarsky)
3027b22 @emezeske Add Felix H. Dahlke and jenanwise to the README.
authored
226 * Felix H. Dahlke (fhd@ubercode.de)
dfa1869 @emezeske Spell out jenanwise' name.
authored
227 * Jenan Wise (http://github.com/jenanwise)
9d17dc0 @emezeske Merge branch '0.1.9'
authored
228 * Kris Jenkins (http://github.com/krisajenkins)
13a229d @emezeske Add Daniel Turczański to the contributor list.
authored
229 * Daniel Turczański (http://jvmsoup.com/)
9b9a2f7 @emezeske Add Brandon Henry to the contributors list.
authored
230 * Brandon Henry (http://brandonhenry.net/)
716dfcb @emezeske Add Daniel Gregoire to the contributors.
authored
231 * Daniel Gregoire (http://techylinguist.com)
Something went wrong with that request. Please try again.