How can I set an environment variable as gulp task?

后端 未结 5 1041
感动是毒
感动是毒 2020-12-23 18:45

I don\'t want type the extra arguments NODE_ENV=\'production\' gulp every time I run gulp to set an environment variable.

I would rather set the environ

5条回答
  •  半阙折子戏
    2020-12-23 19:34

    gulp.task('set-dev-node-env', function() {
        return process.env.NODE_ENV = 'development';
    });
    
    gulp.task('set-prod-node-env', function() {
        return process.env.NODE_ENV = 'production';
    });
    

    Use it like:

    gulp.task('build_for_prod', ['set-prod-node-env'], function() {
        // maybe here manipulate config object  
        config.paths.src.scripts = config.paths.deploy.scripts;
        runSequence(
            'build',
            's3'
        );
    });
    

提交回复
热议问题