How to replace in stream using Gulp?

拥有回忆 提交于 2019-12-04 04:29:21

Nice work :) Looks like gulp-replace might be an easier way for folk coming here from google..

var replace = require('gulp-replace');

gulp.task('templates', function(){
  gulp.src(['file.txt'])
    .pipe(replace(/foo(.{3})/g, '$1foo'))
    .pipe(gulp.dest('build/file.txt'));
});

I finally found the solution!

fs.readFile(injectionFile, 'utf8', function (err, injStr) {
injStr = injStr.replace(/svv/g, cname);

fileStream
.pipe(gulpif(rm!=true,injectString.append(injStr),replace(injStr,'')))
.pipe(concat(initialFile))
.pipe(gulp.dest(animation))

...

It took a while, but I AM HAPPY it's over.

Thank you

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!