function reworkPlugin(stylesheet) {

          // visit each node (selector) in the stylesheet recursively using the official utility method
          visit(stylesheet, function (declarations, node) {

            // each node may have multiple declarations
            declarations.forEach(function (declaration) {

              // reverse the original source-map to find the original sass file
              var cssStart  = declaration.position.start;
              var sassStart = sourceMapConsumer.originalPositionFor({
                line:   cssStart.line,
                column: cssStart.column
              });
              var sassDir = path.dirname(sassStart.source);

              // allow multiple url() values in the declaration
              //  the url will be every second value (i % 2)
              declaration.value = declaration.value
                .split(/url\s*\(\s*['"]?([^'"?#]*)[^)]*\)/g)  // split by url statements
                .map(function (token, i) {
                  return (i % 2) ? (encodeRelativeURL(sassDir, token) || ('url(' + token + ')')) : token;
                }).join('');
            });
          });
        }
/**
         * Plugin for css rework that follows SASS transpilation
         * @param {object} stylesheet AST for the CSS output from SASS
         */
Plugin for css rework that follows SASS transpilation
@param {object} stylesheet AST for the CSS output from SASS
Plugin for css rework that follows SASS transpilation @param { object } stylesheet AST for the CSS output from SASS
function reworkPlugin(stylesheet) {
          visit(stylesheet, function (declarations, node) {
            declarations.forEach(function (declaration) {
              var cssStart  = declaration.position.start;
              var sassStart = sourceMapConsumer.originalPositionFor({
                line:   cssStart.line,
                column: cssStart.column
              });
              var sassDir = path.dirname(sassStart.source);
              declaration.value = declaration.value
                .split(/url\s*\(\s*['"]?([^'"?#]*)[^)]*\)/g)  
                .map(function (token, i) {
                  return (i % 2) ? (encodeRelativeURL(sassDir, token) || ('url(' + token + ')')) : token;
                }).join('');
            });
          });
        }
function reworkPlugin ( stylesheet ) { visit ( stylesheet , function ( declarations , node ) { declarations . forEach ( function ( declaration ) { var cssStart = declaration . position . start ; var sassStart = sourceMapConsumer . originalPositionFor ( { line : cssStart . line , column : cssStart . column } ) ; var sassDir = path . dirname ( sassStart . source ) ; declaration . value = declaration . value . split ( / url\s*\(\s*['"]?([^'"?#]*)[^)]*\) / g ) . map ( function ( token , i ) { return ( i % 2 ) ? ( encodeRelativeURL ( sassDir , token ) || ( 'url(' + token + ')' ) ) : token ; } ) . join ( '' ) ; } ) ; } ) ; }
Plugin for css rework that follows SASS transpilation
 @param {object} stylesheet AST for the CSS output from SASS
Plugin for css rework that follows SASS transpilation @param { object } stylesheet AST for the CSS output from SASS
// visit each node (selector) in the stylesheet recursively using the official utility method // each node may have multiple declarations // reverse the original source-map to find the original sass file // allow multiple url() values in the declaration //  the url will be every second value (i % 2) // split by url statements