EmberApp - ember-cli
EmberApp is the main class Ember CLI uses to manage the Broccoli trees
for your application. It is very tightly integrated with Broccoli and has
a toTree() method you can use to get the entire tree for your application.
Available init options:
- storeConfigInMeta, defaults to
true - autoRun, defaults to
true - outputPaths, defaults to
{} - minifyCSS, defaults to `{enabled: !!isProduction,options: { relativeTo: 'assets' }}
- sourcemaps, defaults to
{} - trees, defaults to
{} - vendorFiles, defaults to
{} - addons, defaults to
{ exclude: [], include: [] }
Static Method Summary
| Static Public Methods | |
|---|---|
| public static |
Returns the environment name |
Constructor Summary
| Public Constructors | |
|---|---|
| public |
EmberApp([defaults], [options={}]) EmberApp is the main class Ember CLI uses to manage the Broccoli trees for your application. It is very tightly integrated with Broccoli and has a |
Method Summary
| Public Methods | |
|---|---|
| public |
dependencies( ): Object |
| public |
import(asset, [options]) Imports an asset into the application. |
| public |
toTree([additionalTrees]): Tree Returns the merged tree for this application |
| Private Methods | |
|---|---|
| private |
_addonDisabledByExclude(addon): Boolean |
| private |
_addonDisabledByInclude(addon): Boolean |
| private |
_addonEnabled(addon): Boolean Checks the result of |
| private |
_concatFiles(tree, options): Delegates to |
| private |
_getAssetPath(asset): (String | Undefined) |
| private |
_import(assetPath, options, directory, subdirectory, extension) |
| private |
Calls the importTransforms hook on addons. |
| private |
_initOptions(options) Initializes the |
| private |
_initProject(options) Initializes the |
| private |
_initTestsAndHinting(options) Initializes the |
| private | |
| private |
Calls the included hook on addons. |
| private | |
| private |
Resolves a path relative to the project's root |
| private |
addonLintTree(type, tree): Tree Runs addon lintTree hooks and returns a single tree containing all their output. |
| private |
addonPostprocessTree(type, tree): Tree Runs addon post-processing on a given tree and returns the processed tree. |
| private |
addonPreprocessTree(type, tree): Tree Runs addon pre-processing on a given tree and returns the processed tree. |
| private |
addonTreesFor(type): Array Returns a list of trees for a given type, returned by all addons. |
| private |
getLintTests( ): Array Runs the |
| private |
Loads and initializes addons for this project. Calls initializeAddons on the Project. |
| private |
Imports legacy imports in this.vendorFiles |
| private |
shouldIncludeAddon(addon): Boolean Returns whether an addon should be added to the project |
| private |
Returns an array of trees for this application |
Static Public Methods
Returns the environment name
Return:
Public Constructors
Public Methods
Imports an asset into the application.
Parameters:
| Name | Type | Attribute | Description |
|---|---|---|---|
| asset | Object | String |
|
Either a path to the asset or an object with environment names and paths as key-value pairs. |
| options | Object |
|
Options object |
| options.type | String |
|
Either 'vendor' or 'test' |
| options.prepend | Boolean |
|
Whether or not this asset should be prepended |
| options.destDir | String |
|
Destination directory, defaults to the name of the directory the asset is in |
| options.outputFile | String |
|
Specifies the output file for given import. Defaults to assets/vendor.{js,css} |
| options.using | Array |
|
Specifies the array of transformations to be done on the asset. Can do an amd shim and/or custom transformation |
Returns the merged tree for this application
Parameters:
| Name | Type | Attribute | Description |
|---|---|---|---|
| additionalTrees | Array |
|
Array of additional trees to merge |
Return:
Tree
Merged tree for this application
Private Methods
Parameters:
| Name | Type | Attribute | Description |
|---|---|---|---|
| addon | Addon |
|
Return:
Parameters:
| Name | Type | Attribute | Description |
|---|---|---|---|
| addon | Addon |
|
Return:
Checks the result of addon.isEnabled() if it exists, defaults to true otherwise.
Parameters:
| Name | Type | Attribute | Description |
|---|---|---|---|
| addon | Addon |
|
Return:
Delegates to broccoli-concat with the sourceMapConfig option set to options.sourcemaps.
Return:
Parameters:
| Name | Type | Attribute | Description |
|---|---|---|---|
| asset | (Object | String) |
|
Return:
(String | Undefined)
assetPath
Calls the importTransforms hook on addons.
Initializes the options property from the options parameter and
a set of default values from Ember CLI.
Parameters:
| Name | Type | Attribute | Description |
|---|---|---|---|
| options | Object |
|
Initializes the project property from options.project or the
closest Ember CLI project from the current working directory.
Parameters:
| Name | Type | Attribute | Description |
|---|---|---|---|
| options | Object |
|
Initializes the tests and hinting properties.
Defaults to false unless ember test was used or this is not a production build.
Parameters:
| Name | Type | Attribute | Description |
|---|---|---|---|
| options | Object |
|
Calls the included hook on addons.
Resolves a path relative to the project's root
Runs addon lintTree hooks and returns a single tree containing all their output.
Parameters:
| Name | Type | Attribute | Description |
|---|---|---|---|
| type | String |
|
Type of tree |
| tree | Tree |
|
Tree to process |
Return:
Tree
Processed tree
private addonPostprocessTree(type, tree): Tree
Runs addon post-processing on a given tree and returns the processed tree.
This enables addons to do process immediately after the preprocessor for a given type is run, but before concatenation occurs. If an addon wishes to apply a transform before the preprocessors run, they can instead implement the preprocessTree hook.
To utilize this addons implement postprocessTree hook.
An example, would be to apply some broccoli transform on all JS files, but only after the existing pre-processors have run.
module.exports = {
name: 'my-cool-addon',
postprocessTree(type, tree) {
if (type === 'js') {
return someBroccoliTransform(tree);
}
return tree;
}
}
Parameters:
| Name | Type | Attribute | Description |
|---|---|---|---|
| type | String |
|
Type of tree |
| tree | Tree |
|
Tree to process |
Return:
Tree
Processed tree
Runs addon pre-processing on a given tree and returns the processed tree.
This enables addons to do process immediately before the preprocessor for a given type is run. If an addon wishes to apply a transform after the preprocessors run, they can instead implement the postprocessTree hook.
To utilize this addons implement preprocessTree hook.
An example, would be to remove some set of files before the preprocessors run.
var stew = require('broccoli-stew');
module.exports = {
name: 'my-cool-addon',
preprocessTree(type, tree) {
if (type === 'js' && type === 'template') {
return stew.rm(tree, someGlobPattern);
}
return tree;
}
}
Parameters:
| Name | Type | Attribute | Description |
|---|---|---|---|
| type | String |
|
Type of tree |
| tree | Tree |
|
Tree to process |
Return:
Tree
Processed tree
Returns a list of trees for a given type, returned by all addons.
Parameters:
| Name | Type | Attribute | Description |
|---|---|---|---|
| type | String |
|
Type of tree |
Return:
Runs the app, tests and templates trees through the chain of addons that produces lint trees.
Those lint trees are afterwards funneled into the tests folder, babel-ified and returned as an array.
Return:
Loads and initializes addons for this project. Calls initializeAddons on the Project.
Imports legacy imports in this.vendorFiles
Returns whether an addon should be added to the project
Parameters:
| Name | Type | Attribute | Description |
|---|---|---|---|
| addon | Addon |
|
Return:
Returns an array of trees for this application