Gulp.js - 在连接时重写嵌入在 css 中的 url

2022-01-12 00:00:00 javascript css gulp

我正在使用 Gulp 连接来自不同目录的多个 css 文件(Bower 管理的依赖项).Font-awesome 是这些依赖项之一,它包含对其字体 url(../font....) 的相对引用.当 css 文件被连接并放置在不同的目录中时,这个相对 url 显然是错误的.是否有处理此问题的最佳实践?

I'm using Gulp to concatenate several css files from different directories (Bower managed dependencies). Font-awesome is one of these dependencies and it contains a relative reference to its fonts url(../font....). When the css file is concatenated and placed in a different directory this relative url will obviously be wrong. Is there a best practice for dealing with this?

推荐答案

另一个选项是 gulp-css-rebase-urls,它是为解决这个问题而构建的.

Another option is gulp-css-rebase-urls which was built to address this problem.

https://www.npmjs.com/package/gulp-css-变基网址

相关文章