使用Gulp在复制过程中重命名一个文件

使用Gulp在复制过程中重命名一个文件,gulp,gulp-rename,Gulp,Gulp Rename,我想自动打包我的Chrome和Firefox扩展,为此我使用Gulp。我在项目的根目录中有两个不同的清单文件,一个用于Chrome,另一个用于Firefox manifest.json和manifestff.json。现在,我想: 将所有需要的内容复制到Chrome扩展的目录中。 对Firefox扩展执行相同的操作,只是我想在此过程中将manifestff.json重命名为manifest.json。 以下是我当前打包Firefox扩展的任务: gulp.task('pack-firefox',

我想自动打包我的Chrome和Firefox扩展,为此我使用Gulp。我在项目的根目录中有两个不同的清单文件,一个用于Chrome,另一个用于Firefox manifest.json和manifestff.json。现在,我想:

将所有需要的内容复制到Chrome扩展的目录中。 对Firefox扩展执行相同的操作,只是我想在此过程中将manifestff.json重命名为manifest.json。 以下是我当前打包Firefox扩展的任务:

gulp.task('pack-firefox', () => {
    return gulp.src([
        'manifestff.json',
        'index.html',
        './public/**'
    ], {'base': '.'})
    .pipe(gulp.dest('./ff'));
}
是否可以使用附加的.pipe指定我要将manifestff.json复制为manifest.json?

查看

const gulp = require('gulp');
const rename = require('gulp-rename');
const gulpIF = require('gulp-if');


gulp.task('pack-firefox', () => {
  return gulp.src([
    'manifestff.json',
    'index.html',
    './public/**'
  ], { 'base': '.' })
    .pipe(gulpIF(function (file) { return file.path.match('manifestff.json') }, rename('manifest.json')))
    .pipe(gulp.dest('./ff'));
});