Addon for Ember-CLI that allows you to defeatureify your code when building for production.
ember install:addon ember-cli-defeatureify
Specify features in your project's Brocfile.js
:
var app = new EmberApp({
defeatureify: {
namespace: 'myNamespace',
features: {
"propertyBraceExpansion": true,
"ember-metal-run-bind": true,
"with-controller": true,
"query-params-new": false,
"string-humanize": false
}
}
})
When building in development
, these features will be inlined in my-app.js
, while they're only used for defeatureifying your code when building in production
. The features are available to you in your application code under myNamespace.FEATURES
.
To use the feature flags, you would wrap the code you want to enable like this:
if(myNamespace.FEATURES.isEnabled('propertyBraceExpansion')) {
// Your code here
} else {
// What to do if feature is disabled
}
Note: If you want to remove Ember debug statements, you will need to use Ember.default
instead of just Ember
in the debugStatements
list.
Namespace defaults to your application name from package.json
, but you can specify your own through the namespace
option.
The namespace is camelized
if it contains dashes, underscores or spaces to make sure it's valid JavaScript and parseable by defeatureify
.
Example:
'my-app-namespace' // myAppNamespace
'app_namespace' // appNamespace
'awesome namespace' // awesomeNamespace
See grunt-ember-defeatureify for more documentation of options.