gulp-defeatureify

Remove specially flagged feature blocks and debug statements from JavaScript as part of your Gulp build process
Information
Package | gulp-defeatureify |
Node Version | >= 0.9.0 |
Gulp Version | 3.x |
defeatureify
is used in the ember-dev
package to enable or remove features and strip debug statements during the Ember.js build process.
This simple plugin exposes defeatureify
as a Gulp plugin so you can use this same process in your own project. (Your project does not need to be an Ember.js application in order to use this plugin.)
Usage
Install
npm install gulp-defeatureify --save-dev
API
defeatureify(options)
options.enableStripDebug
Type: Boolean
Default: false
Enables stripping the debug statements specified in options.debugStatements
.
options.debugStatements
Type: Array
Default: []
An array of strings containing debug statements to remove. Does not use options.namespace
.
Example:
debugStatements: ['App.debugMessage']
options.emberDebugStatements
Type: Boolean
Default: false
Adds the following default Ember debug statements to options.debugStatements
:
debugStatements: [
'Ember.warn',
'Ember.assert',
'Ember.deprecate',
'Ember.debug',
'Ember.Logger.info'
]
options.features
Type: Object
Default: {}
An object containing feature names to enable or disable. Features with a value true
will be enabled, otherwise they will be removed from the source.
Example:
features: {
'some-cool-feature': true,
'ember-metal-run-bind': true,
'with-controller': true,
'query-params-new': false,
'string-humanize': false
}
options.namespace
Type: String
Default: 'Ember'
The namespace to look for the features in.
Usage Examples
Gulpfile
var defeatureify = require('gulp-defeatureify');
var statements = ["Ember.warn", "Ember.assert", "Ember.deprecate", "Ember.debug", "Ember.Logger.info"];
gulp.task('scripts', function() {
gulp.src(['./app/*.js')
.pipe(defeatureify({
debugStatements: statements,
enableStripDebug: true
}))
.pipe(gulp.dest('./dist/'))
});
Stripping Debug Statements
In this example, various Ember
debug statements are configured to be stripped from the source file:
App.IndexRoute = Ember.Route.extend({
model: function() {
Ember.warn('This is a debug statement that will be removed by defeatureify');
return ['red', 'yellow', 'blue'];
}
});
The generated result will be:
App.IndexRoute = Ember.Route.extend({
model: function() {
return ['red', 'yellow', 'blue'];
}
});
See also
License
The MIT License (MIT)
Copyright (c) 2014 Jason Sandmeyer
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.