@@ -11,7 +11,7 @@ module.exports = function gulpCleanCSS(options, callback) {
1111 if ( arguments . length === 1 && Object . prototype . toString . call ( arguments [ 0 ] ) === '[object Function]' )
1212 callback = arguments [ 0 ] ;
1313
14- var transform = function ( file , enc , cb ) {
14+ let transform = function ( file , enc , cb ) {
1515
1616 if ( ! file || ! file . contents )
1717 return cb ( null , file ) ;
@@ -24,21 +24,27 @@ module.exports = function gulpCleanCSS(options, callback) {
2424 if ( file . sourceMap )
2525 options . sourceMap = JSON . parse ( JSON . stringify ( file . sourceMap ) ) ;
2626
27- var style = file . contents ? file . contents . toString ( ) : '' ;
27+ if ( options . rebaseTo ) {
28+
29+ let relative = path . resolve ( file . path , options . rebaseTo ) ;
30+ options . rebaseTo = path . relative ( relative , file . path )
31+ }
32+
33+ let style = file . contents ? file . contents . toString ( ) : '' ;
2834
2935 new CleanCSS ( options ) . minify ( style , function ( errors , css ) {
3036
3137 if ( errors )
3238 return cb ( errors . join ( ' ' ) ) ;
3339
3440 if ( typeof callback === 'function' ) {
35- var details = {
41+ let details = {
3642 'stats' : css . stats ,
3743 'errors' : css . errors ,
3844 'warnings' : css . warnings ,
3945 'path' : file . path ,
4046 'name' : file . path . split ( file . base ) [ 1 ]
41- }
47+ } ;
4248
4349 if ( css . sourceMap )
4450 details [ 'sourceMap' ] = css . sourceMap ;
@@ -50,7 +56,7 @@ module.exports = function gulpCleanCSS(options, callback) {
5056
5157 if ( css . sourceMap ) {
5258
53- var map = JSON . parse ( css . sourceMap ) ;
59+ let map = JSON . parse ( css . sourceMap ) ;
5460 map . file = path . relative ( file . base , file . path ) ;
5561 map . sources = map . sources . map ( function ( src ) {
5662 return path . relative ( file . base , file . path )
0 commit comments