我想自动为Chrome和Firefox打包扩展程序,为此我正在使用Gulp。我在项目的根目录中有两个清单文件,一个用于Chrome,一个用于Firefox(manifest.json
和manifestff.json
)。现在,我要:
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
?
答案 0 :(得分:1)
查看gulp-if
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'));
});