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' }}
  • minifyJS, defaults to `{enabled: !!isProduction}
  • sourcemaps, defaults to {}
  • trees, defaults to {}
  • jshintrc, defaults to {}
  • vendorFiles, defaults to {}
  • addons, defaults to { blacklist: [], whitelist: [] }

Static Method Summary

Static Public Methods
public static
env( ): String

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 toTree() method you can use to get the entire tree for your application.

Method Summary

Public Methods
public
public
import(asset, [options])

Imports an asset into the application.

public
toTree(additionalTrees): Tree

Returns the merged tree for this application

Private Methods
private
private
private

Checks the result of addon.isEnabled() if it exists, defaults to true otherwise.

private
_addonInstalled(addonName): Boolean
private
_concatFiles(tree, options):

Delegates to broccoli-concat with the sourceMapConfig option set to options.sourcemaps.

private
private
private
_contentForAppBoot(content, config)
private
_contentForConfigModule(content, config)
private
_contentForHead(content, config)
private
private
_filterAppTree( ): Tree

Filters styles and templates from the app tree.

private
_getAssetPath(asset): (String | Undefined)
private
_import(assetPath, options, directory, subdirectory, extension)
private

Calls the importTransforms hook on addons.

private
_initOptions(options)

Initializes the options property from the options parameter and a set of default values from Ember CLI.

private
_initProject(options)

Initializes the project property from options.project or the closest Ember CLI project from the current working directory.

private

Initializes the tests and hinting properties.

private
private

Calls the included hook on addons.

private
private
private
private
private
private
private
private
private
private

Resolves a path relative to the project's root

private
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

Returns a list of trees for a given type, returned by all addons.

private

Returns the tree for the app and its dependencies

private
private
contentFor(config, match, type): String

Returns the content for a specific type (section) for index.html.

private
index( ): Tree

Returns the tree for app/index.html

private

Loads and initializes addons for this project. Calls initializeAddons on the Project.

private
javascript( ): Tree

Returns the tree for javascript files

private

Runs the app, tests and templates trees through the chain of addons that produces lint trees.

private
otherAssets( ): Tree

Returns the tree for the additional assets which are not in one of the default trees.

private

Imports legacy imports in this.vendorFiles

private
publicTree( ): Tree

Returns the tree for /public

private

Returns whether an addon should be added to the project

private
styles( ): Tree

Returns the tree for styles

private
testFiles( ): Tree

Returns the tree for test files

private
testIndex( ): Tree

Returns the tree for /tests/index.html

private

Returns an array of trees for this application

Static Public Methods

lib/broccoli/ember-app.js:433

public static env( ): String

Returns the environment name

Return:

String

Environment name

Public Constructors

lib/broccoli/ember-app.js:98

public EmberApp([defaults], [options={}])

Parameters:

Name Type Attribute Description
defaults Object
  • optional
options Object
  • optional
  • default: {}

Configuration options

Public Methods

lib/broccoli/ember-app.js:1620

public dependencies( ): Object

Return:

Object

Alias to the project's dependencies function

lib/broccoli/ember-app.js:1629

public import(asset, [options])

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
  • optional

Options object

options.type String
  • optional
  • default: 'vendor'

Either 'vendor' or 'test'

options.prepend Boolean
  • optional
  • default: false

Whether or not this asset should be prepended

options.destDir String
  • optional

Destination directory, defaults to the name of the directory the asset is in

options.outputFile String
  • optional

Specifies the output file for given import. Defaults to assets/vendor.{js,css}

options.using Array
  • optional

Specifies the array of transformations to be done on the asset. Can do an amd shim and/or custom transformation

lib/broccoli/ember-app.js:1818

public toTree(additionalTrees): Tree

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

lib/broccoli/ember-app.js:472

private _addonDisabledByBlacklist(addon): Boolean

Parameters:

Name Type Attribute Description
addon Addon

Return:

lib/broccoli/ember-app.js:483

private _addonDisabledByWhitelist(addon): Boolean

Parameters:

Name Type Attribute Description
addon Addon

Return:

lib/broccoli/ember-app.js:460

private _addonEnabled(addon): Boolean

Checks the result of addon.isEnabled() if it exists, defaults to true otherwise.

Parameters:

Name Type Attribute Description
addon Addon

Return:

lib/broccoli/ember-app.js:1388

private _addonInstalled(addonName): Boolean

Parameters:

Name Type Attribute Description
addonName String

The name of the addon we are checking to see if it's installed

Return:

lib/broccoli/ember-app.js:445

private _concatFiles(tree, options):

Delegates to broccoli-concat with the sourceMapConfig option set to options.sourcemaps.

Parameters:

Name Type Attribute Description
tree Object
options Object

Return:

lib/broccoli/ember-app.js:838

private _configReplacePatterns( ):

Return:

lib/broccoli/ember-app.js:1163

private _configTree( ):

Return:

lib/broccoli/ember-app.js:1924

private _contentForAppBoot(content, config)

Parameters:

Name Type Attribute Description
content Array
config Object
lib/broccoli/ember-app.js:1907

private _contentForConfigModule(content, config)

Parameters:

Name Type Attribute Description
content Array
config Object
lib/broccoli/ember-app.js:1893

private _contentForHead(content, config)

Parameters:

Name Type Attribute Description
content Array
config Object
lib/broccoli/ember-app.js:1884

private _contentForTestBodyFooter(content)

Parameters:

Name Type Attribute Description
content Array
lib/broccoli/ember-app.js:774

private _filterAppTree( ): Tree

Filters styles and templates from the app tree.

Return:

Tree
lib/broccoli/ember-app.js:1758

private _getAssetPath(asset): (String | Undefined)

Parameters:

Name Type Attribute Description
asset (Object | String)

Return:

(String | Undefined)

assetPath

lib/broccoli/ember-app.js:1679

private _import(assetPath, options, directory, subdirectory, extension)

Parameters:

Name Type Attribute Description
assetPath String
options Object
directory String
subdirectory String
extension String
lib/broccoli/ember-app.js:546

private _importAddonTransforms( )

Calls the importTransforms hook on addons.

lib/broccoli/ember-app.js:205

private _initOptions(options)

Initializes the options property from the options parameter and a set of default values from Ember CLI.

Parameters:

Name Type Attribute Description
options Object
lib/broccoli/ember-app.js:187

private _initProject(options)

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
lib/broccoli/ember-app.js:171

private _initTestsAndHinting(options)

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
lib/broccoli/ember-app.js:341

private _initVendorFiles( )

lib/broccoli/ember-app.js:510

private _notifyAddonIncluded( )

Calls the included hook on addons.

lib/broccoli/ember-app.js:1004

private _podTemplatePatterns( ): Array

Return:

Array

An array of regular expressions.

lib/broccoli/ember-app.js:903

private _processedAppTree( ):

Return:

lib/broccoli/ember-app.js:1033

private _processedBowerTree( ):

Return:

lib/broccoli/ember-app.js:1187

private _processedEmberCLITree( ):

Return:

lib/broccoli/ember-app.js:1119

private _processedExternalTree( ):

Return:

lib/broccoli/ember-app.js:926

private _processedSrcTree( ):

Return:

lib/broccoli/ember-app.js:970

private _processedTemplatesTree( ):

Return:

lib/broccoli/ember-app.js:1014

private _processedTestsTree( ):

Return:

lib/broccoli/ember-app.js:1091

private _processedVendorTree( ):

Return:

lib/broccoli/ember-app.js:331

private _resolveLocal( )

Resolves a path relative to the project's root

lib/broccoli/ember-app.js:1224

private _testAppConfigTree( ):

Return:

lib/broccoli/ember-app.js:694

private addonLintTree(type, tree): Tree

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

lib/broccoli/ember-app.js:620

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

lib/broccoli/ember-app.js:658

private addonPreprocessTree(type, tree): 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

lib/broccoli/ember-app.js:602

private addonTreesFor(type): Array

Returns a list of trees for a given type, returned by all addons.

Parameters:

Name Type Attribute Description
type String

Type of tree

Return:

Array

List of trees

lib/broccoli/ember-app.js:1251

private appAndDependencies( ): Tree

Returns the tree for the app and its dependencies

Return:

Tree

Merged tree

lib/broccoli/ember-app.js:1309

private appTests( )

lib/broccoli/ember-app.js:1835

private contentFor(config, match, type): String

Returns the content for a specific type (section) for index.html.

Currently supported types:

  • 'head'
  • 'config-module'
  • 'head-footer'
  • 'test-header-footer'
  • 'body-footer'
  • 'test-body-footer'

Addons can also implement this method and could also define additional types (eg. 'some-addon-section').

Parameters:

Name Type Attribute Description
config Object

Application configuration

match RegExp

Regular expression to match against

type String

Type of content

Return:

String

The content.

lib/broccoli/ember-app.js:730

private index( ): Tree

Returns the tree for app/index.html

Return:

Tree

Tree for app/index.html

lib/broccoli/ember-app.js:591

private initializeAddons( )

Loads and initializes addons for this project. Calls initializeAddons on the Project.

lib/broccoli/ember-app.js:1398

private javascript( ): Tree

Returns the tree for javascript files

Return:

Tree

Merged tree

lib/broccoli/ember-app.js:1335

private lintTestsTrees( ): Array

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:

lib/broccoli/ember-app.js:1595

private otherAssets( ): Tree

Returns the tree for the additional assets which are not in one of the default trees.

Return:

Tree

Merged tree for other assets

lib/broccoli/ember-app.js:713

private populateLegacyFiles( )

Imports legacy imports in this.vendorFiles

lib/broccoli/ember-app.js:882

private publicTree( ): Tree

Returns the tree for /public

Return:

Tree

Tree for /public

lib/broccoli/ember-app.js:494

private shouldIncludeAddon(addon): Boolean

Returns whether an addon should be added to the project

Parameters:

Name Type Attribute Description
addon Addon

Return:

lib/broccoli/ember-app.js:1442

private styles( ): Tree

Returns the tree for styles

Return:

Tree

Merged tree for styles

lib/broccoli/ember-app.js:1515

private testFiles( ): Tree

Returns the tree for test files

Return:

Tree

Merged tree for test files

lib/broccoli/ember-app.js:859

private testIndex( ): Tree

Returns the tree for /tests/index.html

Return:

Tree

Tree for /tests/index.html

Returns an array of trees for this application

Return:

Array

An array of trees