【问题标题】:Gulp-rev different path in manifest.jsonmanifest.json 中的 Gulp-rev 不同路径
【发布时间】:2017-07-27 03:16:37
【问题描述】:

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

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

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

谢谢

【问题讨论】:

  • 你能发布你的 gulpfile 吗?
  • 我已经解决了,答案如下。无论如何谢谢;)

标签: path gulp manifest gulp-rev manifest.json


【解决方案1】:

对我有用的是使用gulp-rename,然后执行以下操作:

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

但是,最终对我有用的是结合使用 gulp-revgulp-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'));

还为gulp-rev-collector 添加了一个新的rev 任务

// Revision static asset files
gulp.task('rev', () =>
  gulp.src(['build/**/rev-manifest.json', 'build/*.html'])
    .pipe($.revCollector())
    .pipe(gulp.dest('build')),
);

【讨论】:

  • 是的,我已经使用了不太不同的解决方案 -> 我还更改了生成的 manifest.json 插件,但使用 gulp-replace。也谢谢你!
猜你喜欢
  • 1970-01-01
  • 2021-07-03
  • 2016-04-01
  • 1970-01-01
  • 2016-03-22
  • 2017-12-01
  • 1970-01-01
  • 1970-01-01
  • 2020-03-16
相关资源
最近更新 更多