2

Why does gulp code below remove my relative paths?

I am using clean-css:

gulp.task('build-css', function() {
    return gulp.src([
        'style.css',
        ])
        .pipe(sourcemaps.init())
        .pipe(cleanCSS({debug: true}))
        .pipe(concat('bundle.min.css'))
        .pipe(sourcemaps.write('./maps'))
        .pipe(gulp.dest('dist'))
        .pipe(livereload());
});

Original css:

@font-face {
  font-family: 'icomoon';
  src:  url('../fonts/social-media/icomoon.eot?mh2h47');
  src:  url('../fonts/social-media/icomoon.eot?mh2h47#iefix') format('embedded-opentype'),
    url('../fonts/social-media/icomoon.ttf?mh2h47') format('truetype'),
    url('../fonts/social-media/icomoon.woff?mh2h47') format('woff'),
    url('../fonts/social-media/icomoon.svg?mh2h47#icomoon') format('svg');
  font-weight: normal;
  font-style: normal;
}

After minifying with gulp:

@font-face{font-family:icomoon;src:url(fonts/social-media/icomoon.eot?mh2h47);src:url(fonts/social-media/icomoon.eot?mh2h47#iefix)

How can I keep these relative paths?

Emile Bergeron
  • 17,074
  • 5
  • 83
  • 129
Run
  • 54,938
  • 169
  • 450
  • 748

1 Answers1

3

Try setting the rebase option to false (true is the default) so that your paths are not modified by cleanCSS.

.pipe(cleanCSS( {debug: true, rebase: false} )
Mark
  • 143,421
  • 24
  • 428
  • 436