gulp-env-change
v1.0.1
Published
Change process.env.NODE_ENV in gulp scripts
Downloads
2
Readme
gulp-env-change
Change NODE_ENV in a gulp chain
why?
To change NODE_ENV for specific tasks in your build chain.
If using a single image for deployment over dev/staging/prod, building with NODE_ENV='production' might not be an acceptable solution, this plugin allows you switch NODE_ENV for specific tasks (such as minifying+uglifying a production version without requiring a separate build).
installation
$ npm install --save-dev gulp-env-change
#usage
import envChange from 'gulp-env-change';
gulp.task('foo', () => {
return gulp.src('./src/*.js')
.pipe(envChange({environment: 'production'}) // switch NODE_ENV to production for uglify
.pipe(rename({suffix: '.min'})
.pipe(uglifyjs())
.pipe(envChange({environment: 'reset'}) // switch NODE_ENV back to previous setting
.pipe(gulp.dest('./target/'))
});