Accept a src config, add docs

This commit is contained in:
Tim Schaub
2014-04-11 15:42:47 -06:00
parent a28db38eef
commit 758eed357e
2 changed files with 27 additions and 10 deletions
+16 -6
View File
@@ -17,25 +17,35 @@ Build configuration files are JSON files that are used to determine what should
* **compile** - `Object` An object whose properties are [Closure Compiler options](https://github.com/openlayers/closure-util/blob/master/compiler-options.txt). Property names match the option names without the `--` prefix (e.g. `"compilation_level": "ADVANCED_OPTIMIZATIONS"` would set the `--compilation_level` option). Where an option can be specified multiple times, use an array for the value (e.g. `"externs": ["one.js", "two.js"]`). Where an option is used as a flag, use a boolean value (e.g. `"use_types_for_optimization": true`).
* **src** - `Array.<string>` Optional array of [path patterns](https://github.com/isaacs/minimatch/blob/master/README.md) for source files. This defaults to `["src/**/*.js"]` which will match all `.js` files in the `src` directory. To include a different set of source files, provide an array of path patterns. Note that these patterns are `/` delimited even on Windows.
The build task generates a list of source files sorted in dependency order and passes these to the compiler. This takes the place of the `--js` options that you would use when calling the compiler directly. If you want to add additional source files, typically you would use the `src` array described above. This works with sources that have `goog.require` and/or `goog.provide` calls (which are used to sort dependencies). If you want to force the inclusion of files that don't use `goog.require` or `goog.provide`, you can use the `js` property of the `compile` object. Paths in the `js` array will be passed to the compiler **after** all other source files.
Paths in your config file should be relative to the current working directory (when you call `node tasks/build.js`). Note that this means paths are not necessarily relative to the config file itself.
Below is a complete `build.json` configuration file that would generate a build including every symbol in the library (much more than you'd ever need).
```json
{
"exports": ["*"],
"compile": {
"compilation_level": "ADVANCED_OPTIMIZATIONS",
"use_types_for_optimization": true,
"externs": [
"externs/olx.js",
"externs/bingmaps.js",
"externs/geojson.js",
"externs/oli.js",
"externs/geojson.js"
"externs/olx.js",
"externs/proj4js.js",
"externs/tilejson.js",
"externs/topojson.js",
"externs/vbarray.js"
],
"define": [
"ol.ENABLE_PROJ4JS=false",
"goog.dom.ASSUME_STANDARDS_MODE=true",
"goog.DEBUG=false"
],
"output_wrapper": "(function(){%output%})();"
"compilation_level": "ADVANCED_OPTIMIZATIONS",
"output_wrapper": "(function(){%output%})();",
"use_types_for_optimization": true
}
}
```