[英]Setting NODE_ENV via envify not working
I have the following gulp
task in my gulpfile.js
: 我有以下gulp
在我的任务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: 任务完成,状态为0, React
转换发生,但在bundle.js
我仍然看到:
if (process.env.NODE_ENV !== 'production') {
Wasn't this supposed to go away with the envify
transform? 这不应该随着envify
变换而envify
吗? 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). 我已经做了一些挖掘,但我能找到的所有解决方案都是os x / linux特定的(我在windows机器上)。
EDIT: I am running the gulp build from within visual studio's Task Runner Explorer
. 编辑:我在visual studio的Task Runner Explorer
运行gulp build。
The doc says: 医生说:
By default, environment variables that are not defined will be left untouched. 默认情况下,未定义的环境变量将保持不变。
https://github.com/hughsk/envify#purging-processenv https://github.com/hughsk/envify#purging-processenv
Have you tried defining it before running that? 在运行之前你尝试过定义吗? ie 即
process.env.NODE_ENV = 'production';
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.