Builders
Builder is a property of BuildConfig defining entry point of the gulp task to be created. Curently, following builder types are available.
- BuilderClassName
- BuildFunction
- ExternalCommand
- GBuilder
- 'cleaner'
- 'watcher'
BuilderClassName
Class name, in string type, of built-in builders or user defined class derived from GBuilder.
Example:
If BuilderClassName is used, the class definition file with the name is searched in the custom directory locations specified by ProjectOptions.customBuildDirs first. If no file found, then built-in builders are searched for the mathing. This sequence gives a chance to override built-in builder classes with the same name. If no builder is specified, default function which does nothing is assigned. Refer to ProjectOptions for more information on customBuildDirs option.
BuildFunction
This is a function to be executed for build process. RTB instance is passed as its first argument. If it returns promise, build task is not finished until the promise is fullfilled. Optional arguments(args) are delivered if available. Refer to Extension for example of using optional arguments.
Example:
ExternalCommand
Builder can be an external command object with following data type:
property | description |
---|---|
command | command name that can be executed by process.spawn() function |
args | command line argument list |
options | Accepts all the options for process.spawn() function and the followings |
options.silent | Suppress all the output messages |
options.verbose | Print excessive messages |
options.sync | Excutes the command in sequence by calling order of other build routines in sync mode. Refer to [RTB] section for more information. |
Example:
GBuilder
GBuilder is a built-in class that copies files listed in conf.src to conf.dest. This is a base class that all the built-in classes are derivatived from. It has a member function build() which is executed by gulp task. Custom classes can also defined by extending GBuilder and defining its own build function. If the build function returns promise, build task is not finished until the promise is fullfilled.
GBuilder interface:
Built-in Builders
Currently, following built-in builders are available:
- GBuilder
- GCoffeeScriptBuilder
- GConcatBuilder
- GCSSBuilder
- GImagesBuilder
- GJavaScriptBuilder
- GMarkdownBuilder
- GPaniniBuilder
- GRTLCSSBuilder
- GTwigBuilder
- GTypeScriptBuilder
- GWebpackBuilder
- GZipBuilder
Built-in builders are available from tron.builders property. Typically in BuildConfig, BuilderClassName is used rather than directly creating GBuilder class instances.
Example
Custom Builders
Custom builder class can be defined by extending tron.builders.GBuilder and redefining builder() function.
Example
cleaner
Predefined built-in builder, Cleaner. Refer to CleanerConfig for more information.
watcher
Predefined built-in builder, Watcher. Refer to WatcherConfig for more information.