gulp-css-path

1.0.0 • Public • Published

amdefine

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.

Package Sidebar

Install

npm i gulp-css-path

Weekly Downloads

32

Version

1.0.0

License

ISC

Unpacked Size

4.2 kB

Total Files

4

Last publish

Collaborators

  • xieguishi