How can I use gulp to replace a string in a file?

后端 未结 4 1527
执笔经年
执笔经年 2021-01-01 10:40

I am using gulp to uglify and make ready my javascript files for production. What I have is this code:

var concat = require(\'gulp-concat\');
var del = requi         


        
4条回答
  •  佛祖请我去吃肉
    2021-01-01 11:12

    There I have a versioning specific example for your reference. let say you have version.ts file and it contains the version code inside it. You now can do as the follows:

    gulp.task ('version_up', function () {
        gulp.src (["./version.ts"])
            .pipe (replace (/(\d+)\.(\d+)(?:\.(\d+))?(?:\-(\w+))?/, process.env.VERSION))
            .pipe (gulp.dest ('./'))
    });
    

    the above regex works for many situation on any conventional version formats.

提交回复
热议问题