Skip to content

Building deployment artifacts

Craig Andera edited this page Jan 25, 2012 · 6 revisions

Building deployment artifacts

Once the application is finished, you will want to create the artifacts which can be deployed. This includes the application's JavaScript compiled in advanced mode, the host HTML page and all of the resources in the public directory. Remember that the host page does not exist during development but is generated dynamically.

From the top level of your project, run the following commands.

lein run -m script.build
lein run -m script.serve

lein run -m script.build will generate all of the deployment artifacts in a directory named out at the top level of your project. lein run -m script.serve will run the production server which will serve this application as well as the backend API.

The produced out directory will have the basic structure shown below:

out
└── public
    ├── 404.html
    ├── css
    │   └── one.css
    ├── images
    │   └── favicon.ico
    ├── index.html
    └── javascripts
        └── mainp.js

The file index.html is the host page for the application and is generated when you run lein run -m script.build. If the application does not use a backend (it is pure JavaScript) then you can open the index.html file directly in a browser and everything will work. If the application does use a Clojure backend then you will need to start a server.

The sample application has a backend API and therefore a server is required for the application to work properly. A production server is implemented in the file src/app/clj/one/sample/prod_server.clj and can be run by executing lein run -m script.serve.

The index.html host file is generated using the same application.html template that was used during development. To transform this file for the production application, add a transformation function to the application configuration (src/app/clj/one/sample/config.clj) under the :prod-transform key. The sample application uses a transformation function which will remove the ClojureScript One navigation menu.