jsbuild
jsbuild is a command line utility for minifying and concatenating scripts from JavaScript libraries.
Usage
jsbuild <config_file> [options]
Options:
- -h [--help]
- Show this help message and exit.
- -u [--uncompress]
- Don't compresses aggregated JavaScript.
- -v [--verbose]
- Print more info while building.
- -o [--output=] OUTPUT_DIR
- Output directory for built script.
- -r [--resource=] RESOURCE_DIR
- Resource base directory (used for variable interpolation in config file).
- -s [--single=] SECTION
- Only create file for this section.
Examples
Build all sections in the all.cfg file - writing the results to the current directory.
jsbuild all.cfg
Build all sections in the all.cfg file - using the verbose option and writing the results to a different directory.
jsbuild all.cfg -v -o ../script
Build just one section of the all.cfg file.
jsbuild all.cfg -s MyLib.js
Configuration Files
Configuration Format
A config file is divided into sections - one uniquely named section per output file.
A section is formatted in the following fashion:
[Output.js]
root=path/to/where/files/are
license=path/to/license/for/these/libs
first=
3rd/prototype.js
core/application.js
core/params.js
last=
core/api.js
exclude=
3rd/logger.js
#...
The files listed in the first section will be forced to load *before* all other files (in the order listed). The files in last section will be forced to load *after* all the other files (in the order listed).
The files list in the exclude section will not be imported.
The configuration allows for the interpolation of variables defined in the config file. %(resource-dir)s may be subsituted for the value of the -r flag.
Lines commented using '#' will be ignored.
Dependency Syntax
File merging uses declarations inside the candidate JavaScript files to determine dependencies. Two types of dependencies are specified with two different comment formats within source files.
To specify that a target files must be included before a given source file, include a comment of the following format:
// @requires <file path>
e.g.
// @requires Geo/DataSource.js
To specify that a target file must be included at any place in the merged build - before or after a given source file - include a comment in the source file of the following format:
// @include <file path>
e.g.
// @include Geo/DataSource.js
Note that the exclude list in a configuration file will override dependencies specified by the @requires and @include comment directives described above.
