You configure Shaker in the application.json file or create a separate file called shaker.json. For simplicity, we recommend using application.json. If both exist, Shaker will merge the configurations of both files, giving precedence to configurations in application.json.
In Mojito, most of the JSON configuration files use Yahoo! Configuration Bundle (YCB), meaning your configurations get merged based on the context being used and the order of the contexts set in your dimension.json file. For more information, see Using Context Configurations in the Mojito documentation.
[
{
"settings": [ "master" ],
"shaker": {
//shaker default config
}
},
{
"settings": [ "environment:dev" ],
"shaker": {
//shaker config for dev
}
},
"settings": ["environment: my-syntethic-env"],
"shaker":{
//other config
}
]
As we mention in the Usage chapter, Shaker and Mojito will choose the configuration set for a particular context. For example, the following command will merge the configurations of "settings: master" and "settings: environment:dev":
$ mojito shake --context "environment:dev"
| Property | Data Type | Required? | Default Value | Possible Values | Description |
|---|---|---|---|---|---|
| task | string | no | raw | raw, local, s3, mobstor, your own See Env and Context Configuration. | Defines how the rollups will be deployed. |
| module | string | no | null | N/A | Defines how the rollups will be deployed. |
| taskConfig | object | no | null | See: Object taskConfig. | Defines how the rollups will be deployed. |
| minify | boolean/Object | no | true | See: Object minifyConfig. | Specifies whether to minify the rollups. |
| jslint | boolean | no | true | N/A | Specifies whether to jslint the rollups. |
| regexp | string | yes, if replaced | null | Regular expression to match | Defines a regular expression to match in the rollups. |
| replace | string | no | null | Replacement string | Defines the string that replaces what is matched by the regular expression. |
| comboCDN | boolean | no | false | N/A | Specifies to push all the application resources to CDN. YUI and taskConfig are needed. |
| optimizeBootstrap | boolean | no | false | N/A | Creates a optimized way to load all bootstrap JS files in parallel without blocking the rendering of the page. See Usage for more info. |
| rollupConfig | object | no | null | See Object rollupConfig. | Specifies which resources to rollup for each mojit (views, langs, controller, ...). |
| routeBundle | object | no | null | See Object routeBundle. | Specifies which mojits to bundle together for each entry point defined in our application. |
| appBundle | boolean | no | false | N/A | Bundles all the resources of our application. |
| filterInCore | array | no | null | Mojito core modules | Filters the specified Mojito core modules from being included in the core bundle. |
Allows you to configure your task in case you create your own task or are using some third-party module to push to a CDN.
| Property | Data Type | Required? | Default Value | Possible Values | Description |
|---|---|---|---|---|---|
| prefix | string | no | null | raw, local, s3, mobstor, your own See Env and Context Configuration. | Defines how the rollups will be deployed. |
| <taskName> | object | no | null | N/A | Defines the configuration properties for a given task (for more info check the FAQ). |
Further JS/CSS minify options.
| Property | Data Type | Required? | Default Value | Possible Values | Description |
|---|---|---|---|---|---|
| js | object | no | null | See Object jsminifyConfig. | Defines JS minify options. |
| css | object | no | null | N/A | Defines CSS minify options. Currently not supported. |
| Property | Data Type | Required? | Default Value | Possible Values | Description |
|---|---|---|---|---|---|
| mangle | boolean | no | false | N/A | Whether mangle variable names. |
| squeeze | boolean | no | false | N/A | Does various optimizations that result in smaller, less readable code. |
You can define which parts you want to rollup for each mojit. If your application is offline, you may want to rollup all the components. If you just want to have the minimum shipped to the client, use the default for bundleBinders.
| Property | Data Type | Required? | Default Value | Possible Values | Description |
|---|---|---|---|---|---|
| bundleBinders | boolean | no | true | N/A | Includes binders and their dependencies in the rollups. |
| bundleViews | boolean | no | false | N/A | Includes and compile (as a JS module) views in the rollups. |
| bundleController | boolean | no | false | See Object taskConfig. | Includes controller and its dependencies and the proper languages in the rollups. |
| bundleAll | boolean | no | false | See Object taskConfig. | Bundles all possible resources for each mojit. |
Route bundle allow you to precompute and rollup high-coverage mojits (see Bundle Mojits for detailed information), so you can optimize your startup time. The keys of the object correspont to routes you define in routes.json, and the values are arrays of mojits and their actions to bundle together. The default action is index.
The example shaker configuration below maps routes to mojit actions with routeBundle:
"shaker": {
"routeBundle": {
"myRoute1": [
Mojit1.index,
Mojit2.index,
Mojit3.otherAction
],
"myRoute2": [
//mojit and action list
]
}
}