0

我现在正在尝试使用 gulp-rev 生成 manifest.json 文件。我需要的是这样的:

     {
      "img/image.jpg": "folder/img/image-34c9d558b2.jpg";
}

我如何将那个“文件夹”放在那里的路径中?我试图使用 gulp-rev-collector 但它不是很有用。有人可以给我一个例子吗?

谢谢

4

1 回答 1

1

对我有用的是使用gulp-rename然后做类似的事情:

.pipe($.rename({
  dirname: 'styles',
}))
.pipe($.rev.manifest('manifest.json', {
  cwd: 'build',
  merge: true,
}))

但是,最终对我有用的是gulp-rev与 结合使用gulp-rev-collector,后者根据清单文件中的映射替换链接。

所以像:

.pipe($.rename({
  dirname: 'styles',
}))
.pipe($.rev())
.pipe(gulp.dest('build'))
.pipe(gulp.dest('.tmp/styles'))
.pipe($.rev.manifest())
.pipe(gulp.dest('build/styles'));

并且还添加了一个新rev任务gulp-rev-collector

// Revision static asset files
gulp.task('rev', () =>
  gulp.src(['build/**/rev-manifest.json', 'build/*.html'])
    .pipe($.revCollector())
    .pipe(gulp.dest('build')),
);
于 2017-07-26T19:07:19.430 回答