gulp-css-path: 转换CSS文件中的图片路径为绝

Images in the CSS file path can be converted into an absolute path, and add the CDN prefix

Install

npm install gulp-css-path --save-dev Usage

const cssUrlToAbsolute = require('gulp-css-path'); gulp.task('CSS_build', function() { return gulp.src(['./src/**/*.css']) .pipe(cssUrlToAbsolute({ //relative path root: './src', //cdn prefix cdnpath: '//img.xxx.com/dist/img/' })) .pipe(gulp.dest(DIST_PATH)) }); example

1) css

.label { width: 57px; height: 69px; background: url(../../common/img/label.png) center center no-repeat; }

2) convert after

.label { width: 57px; height: 69px; background: url(//img.xxx.com/dist/img/help/label/common/img/label.png) center center no-repeat; } License

New BSD and MIT. Check the LICENSE file for all the details.

版权声明:

1、该文章(资料)来源于互联网公开信息,我方只是对该内容做点评,所分享的下载地址为原作者公开地址。
2、网站不提供资料下载,如需下载请到原作者页面进行下载。