如何用 gulp-rev 的输出替换 index.html 中列出的文件名? [英] How do I replace the filenames listed in index.html with the output of gulp-rev?

查看:9
本文介绍了如何用 gulp-rev 的输出替换 index.html 中列出的文件名?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用 gulp-rev 构建可以设置为 永不过期.我想将 index.html 中生成的文件的所有引用替换为这些重命名的文件,但我似乎找不到任何类似 Grunt 和 usemin 的东西.

I'm using gulp-rev to build static files that I can set to never expire. I'd like to replace all references to the generated files in index.html to these renamed files, but I can't seem to find anything that does that like Grunt with usemin.

据我目前所知,我有一些选择.

As far as I can tell right now, I have some options.

  1. 使用 gulp-usemin2,这取决于 gulp-rev.当我去搜索 Gulp 插件 时,它说 gulp-usemin2 做得太多所以我应该使用 gulp-useref 代替,但我无法将 gulp-ref 配置为使用 gulp-rev 的输出.
  2. 编写我自己的插件,用生成的文件替换 index.html(和 CSS)中的块(脚本和样式).
  1. Use gulp-usemin2, which depends on gulp-rev. When I go to search Gulp plugins, it says that gulp-usemin2 does too much so I should use gulp-useref instead, but I can't configure gulp-ref to use gulp-rev's output.
  2. Write my own plugin the replace the blocks (scripts & styles) in index.html (and in the CSS) with the generated files.

有什么想法吗?我不明白为什么这个小用例应该是我替换 Grunt 的唯一方法.

Any ideas? I don't see why this little use case should be the only thing in my way to replacing Grunt.

推荐答案

我没有尝试通过多个 gulp 步骤来解决这个问题(gulp-rev 似乎希望你这样做),而是将 gulp-rev fork 到 gulp-rev-all 在一个 gulp 插件中解决这个用例.

Rather than trying to solve this problem multiple gulp steps (which gulp-rev seems to want you to do), I've forked gulp-rev to gulp-rev-all to solve this usecase in one gulp plugin.

对于我的个人用例,我想彻底修改所有内容,但是当其他人提出功能请求时,应该能够排除某些文件,例如 index.html.这将很快实施.

For my personal usecase I wanted to rev absolutely everything but as someone else raised an feature request, there should be the ability to exclude certain files like index.html. This will be implemented soon.

这篇关于如何用 gulp-rev 的输出替换 index.html 中列出的文件名?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆