pather.js
function getRelativePath(cssPath, importCssPath, imgPath) {
        var count1 = 0,
            count2 = 0,
            result = '';
        importCssPath = getFilePath(cssPath, importCssPath);
        imgPath = getFilePath(importCssPath, imgPath);
        for (var i = 0, length = cssPath.length; i < length; i++) {
            if (cssPath[i] == imgPath[i]) {
                count1++;
            } else {
                break;
            }
        }
        count2 = cssPath.length - count1 - 1;
        for (var i = 0; i < count2; i++) {
            result += '../';
        }
        result = result + imgPath.splice(count1).join('/');
        return result;
    }
function getRelativePath(cssPath, importCssPath, imgPath) {
        var count1 = 0,
            count2 = 0,
            result = '';
        importCssPath = getFilePath(cssPath, importCssPath);
        imgPath = getFilePath(importCssPath, imgPath);
        for (var i = 0, length = cssPath.length; i < length; i++) {
            if (cssPath[i] == imgPath[i]) {
                count1++;
            } else {
                break;
            }
        }
        count2 = cssPath.length - count1 - 1;
        for (var i = 0; i < count2; i++) {
            result += '../';
        }
        result = result + imgPath.splice(count1).join('/');
        return result;
    }
function getRelativePath ( cssPath , importCssPath , imgPath ) { var count1 = 0 , count2 = 0 , result = '' ; importCssPath = getFilePath ( cssPath , importCssPath ) ; imgPath = getFilePath ( importCssPath , imgPath ) ; for ( var i = 0 , length = cssPath . length ; i < length ; i ++ ) { if ( cssPath [ i ] == imgPath [ i ] ) { count1 ++ ; } else { break ; } } count2 = cssPath . length - count1 - 1 ; for ( var i = 0 ; i < count2 ; i ++ ) { result += '../' ; } result = result + imgPath . splice ( count1 ) . join ( '/' ) ; return result ; }
get images' relative path after css merging
@param {String} cssPath css absolute file path
@param {String} importCssPath relative imported css file path
@param {String} imgPath raw image relative path
get images relative path after css merging