Get unlimited public & private packages + package-based permissions with npm Pro.Get started »

gulp-mode

1.0.2 • Public • Published

node-gulp-mode

A gulp plugin for identifying build mode.

Circle CI npm version npm downloads npm license Dependency Status

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");
}

Install

npm i gulp-mode

DownloadsWeekly Downloads

2,082

Version

1.0.2

License

MIT

Last publish

Collaborators

  • avatar