Usage

Clover uses the YAML format for configuration files. At a minimum, the configuration file declares the list of files that should be compiled (inputs option), where their dependencies can be found (paths option) and various other options.

The following as an example of a minimal configuration file:

id: example
output: compiled.js
paths:
- .
inputs:
- main.js

Once clover starts, it will discover new JavaScript and Soy files added under the specified paths.

Tip

It is often easiest to declare a single file for inputs, such as main.js.

goog.require() and goog.provide() should be used as appropriate to transitively include the desired libraries for the application.

This avoids the need to restart clover and makes the insertion point for your application unambiguous.

For development

When clover is started in server mode, it takes the path to one or more config files as input:

clover serve clover.yaml

The primary way to access the output of the clover server is by making a GET request. By default, clover runs on port 2323.

Loading the following URL in a browser will return the compiled code for the configuration with the specified id:

http://localhost:2323/configs/example/output.js

This means that when developing your web application, you will need a <script> tag whose src attribute refers to the URL that is shown above:

<script src="http://localhost:2323/configs/example/output.js"></script>

Note

You will need to add logic to your web server to load JavaScript from clover in development mode, but to load JavaScript from wherever your other static content is hosted in production mode.

For testing

Refer to javascript-testing for how to write and run unit tests.

For Production

clover is designed to produce a static JavaScript file that can be served in production.

The output-file option allows one to specify an output destination.

If no output file is specified, the compilation will be printed to standard output.

The following command will compile to the output specified:

clover build clover.yaml <config id>