gulp-mode
v1.1.0
Published
A gulp plugin for identifying biuld mode.
Downloads
13,937
Maintainers
Readme
node-gulp-mode
A gulp plugin for identifying build mode.
Install
With npm do:
$ npm install --save-dev gulp-mode
Usage
var gulp = require('gulp');
var mode = require('gulp-mode')();
var uglify = require('gulp-uglify');
gulp.task('default', function() {
gulp.src('src/*.js')
.pipe(mode.production(uglify()))
.pipe(gulp.dest('dist'));
});
To specify mode
% gulp --production
or
% NODE_ENV=production gulp
API
Construct
var mode = require('gulp-mode')([*options*]);
Options:
| name | type | description | default value |
|-------------|---------|---------------------------------------|-------------------------------|
| modes | array | List of mode name. | ["production", "development"] |
| default | string | Default mode. Must be in the modes
. | "development" |
| verbose | boolean | Show verbose messages. | false |
Example:
var mode = require('gulp-mode')({
modes: ["production", "development"],
default: "development",
verbose: false
});
Evaluate the mode
To evaluate the mode,
mode.<mode name>(callback)
Example:
gulp.src('src/*.js')
.pipe(mode.production(uglify()))
.pipe(gulp.dest('dist'));
Get current mode
To get current mode as boolean
mode.<mode name>();
Example:
var isProduction = mode.production();
if(isProduction) {
console.log("Production mode");
}