--这是为我的部署构建创建版本化文件夹的第1步。
如何将字符串传入下面的gulp.task?
gulp.task('build', function(cb) {
runSequence('html-templates',
'stx-css',
'app-css',
'stx-js',
'app-js',
'build:copy',
'build:remove',
'build:index', cb);
});我想这样做:gulp build 1.0.1,然后将字符串1.0.1传递给Gulpfile。
gulp.task('build', function(version, cb) {
console.log('version = ', version);
runSequence('html-templates',
'stx-css',
'app-css',
'stx-js',
'app-js',
'build:copy',
'build:remove',
'build:index', cb);
});发布于 2015-07-16 17:01:09
这可以使用env变量来完成!
主题的伟大视频: https://www.youtube.com/watch?v=gRzCAyNrPV8
所以我把这个添加到我的Gulpfile中:
var env = process.env.V; // V={version number}然后添加了一个version任务,该任务调用一个函数以打印出在调用构建任务之前传入的字符串:
gulp.task('build', function(cb) {
runSequence('version',
'html-templates',
'stx-css',
'app-css',
'stx-js',
'app-js',
'build:copy',
'build:remove',
'build:index', cb);
});
gulp.task('version', function() {
return printOut(env);
});
function printOut(version) {
console.log('version = ',version);
}

https://stackoverflow.com/questions/31459648
复制相似问题