Skip to content
Brenton Ashworth edited this page Jan 10, 2012 · 10 revisions

Workflow

When working with ClojureScript, having a good workflow is essential. The first thing to know about workflow is that you should be working from the REPL as much as possible. In fact, if you are not spending most of your time in the REPL, you're doing it wrong.

Using the REPL as the main way to deliver code to the browser means never having to refresh the page. One could theoretically build an entire application without a single page refresh. If you find yourself refreshing the page after every change you make, you're doing it wrong. What is this, 2009?

The documentation in this wiki will often encourage you to start a REPL and follow along. We suggest that you follow this advice as much as possible. The best way to understand the sample application and to learn how to work with any ClojureScript application is to follow along while reading through this wiki.

As you begin working on your own applications, it is important to have a development tool that allows you to edit source code and easily evaluate it in a REPL. Emacs is great for this. If you're not into Emacs, there are other options.

Design -> Development -> Production

ClojureScript One is a development tool which also hosts the application being developed. By default, the tool gives you three views of your application: Design, Development and Production.

Before you begin doing anything with ClojureScript One, you should first have a plan for what you are going to build. The plan should, at least, include the views that you would like to render and the events that cause you to transition between views.

With this plan in place, your first stop should be the Design view. In this view you use HTML, CSS and Images to create static views for your application. You can treat these as templates which may be dynamically manipulated and rendered at runtime.

Having this separate view of static resources is very helpful for both developers and designers.

Once the static views have been created, the Development area allows you to run, interact with and build your application. The JavaScript running on this page is produced by the ClojureScript compiler alone. The application is not optimized or minified. Each input ClojureScript file becomes one JavaScript file. This makes debugging a little easier.

ClojureScript supports another kind of compilation which performs optimizations, dead-code elimination and minification. This is called "advanced compilation" and should be checked periodically. The Production view hosts the advanced compiled version of the application. Visiting this view will cause your application to be compiled. Even though ClojureScript supports advanced compilation, it is still possible to do things that will break it. This check should be performed regularly.

When looking at the advanced compiled version of an application, notice that all of the JavaScript lives in one minified JavaScript file. You will find the compiled JavaScript files in the public/javascripts folder by default as you proceed through the tutorial.

Deploy

When you are ready to deploy your application, run the script script/build. This will generate the host page, advanced compiled JavaScript and all of the resources that you will need to deploy. Output from script/build will go into the out directory at the root level of your project.