I have the following gulp
task in my gulpfile.js
:
gulp.task('build-scripts', function () {
var b = browserify({ debug: false });
b.transform(reactify);
b.transform(envify({
_: 'purge',
NODE_ENV: 'production'
}));
b.add('./src/scripts/index.js');
return b.bundle()
.pipe(source('./www/scripts/dist/bundle.js'))
.pipe(buffer())
.pipe(uglify())
.pipe(gulp.dest('.'))
});
The task completes with status 0 and the React
transform happens, but in bundle.js
I still see:
if (process.env.NODE_ENV !== 'production') {
Wasn't this supposed to go away with the envify
transform? Am I doing something wrong here?
I have done some digging, but all the solutions I can find are os x / linux specific (I'm on a windows machine).
EDIT: I am running the gulp build from within visual studio's Task Runner Explorer
.
The doc says:
By default, environment variables that are not defined will be left untouched.
https://github.com/hughsk/envify#purging-processenv
Have you tried defining it before running that? ie
process.env.NODE_ENV = 'production';
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.