src/index.js
function processUrl(result, decl, node, opts) {
    // ignore from the css file by `!`
    if (node.value.indexOf('!') === 0) {
        node.value = node.value.slice(1);
        return Promise.resolve();
    }

    if (
        node.value.indexOf('/') === 0 ||
        node.value.indexOf('data:') === 0 ||
        node.value.indexOf('#') === 0 ||
        /^[a-z]+:\/\//.test(node.value)
    ) {
        return Promise.resolve();
    }

    /**
     * dirname of the read file css
     * @type {String}
     */
    const dirname = path.dirname(decl.source.input.file);

    let fileMeta = getFileMeta(
        dirname,
        decl.source.input.file,
        node.value,
        opts
    );

    // ignore from the fileMeta config
    if (ignore(fileMeta, opts)) {
        return Promise.resolve();
    }

    return copy(
        fileMeta.absolutePath,
        () => fileMeta.resultAbsolutePath,
        (contents, isModified) => {
            fileMeta.contents = contents;

            return Promise.resolve(
                isModified ? opts.transform(fileMeta) : fileMeta
            )
                .then(fileMetaTransformed => {
                    fileMetaTransformed.hash = opts.hashFunction(
                        fileMetaTransformed.contents
                    );
                    let tpl = opts.template;
                    if (typeof tpl === 'function') {
                        tpl = tpl(fileMetaTransformed);
                    } else {
                        tags.forEach(tag => {
                            tpl = tpl.replace(
                                '[' + tag + ']',
                                fileMetaTransformed[tag] || opts[tag] || ''
                            );
                        });
                    }

                    const resultUrl = url.parse(tpl);
                    fileMetaTransformed.resultAbsolutePath = decodeURI(
                        path.resolve(
                            opts.dest,
                            resultUrl.pathname
                        )
                    );
                    fileMetaTransformed.extra = (resultUrl.search || '') +
                        (resultUrl.hash || '');

                    return fileMetaTransformed;
                })
                .then(fileMetaTransformed => fileMetaTransformed.contents);
        }
    ).then(() => {
        const destPath = defineCSSDestPath(
            dirname,
            fileMeta.basePath,
            result,
            opts
        );

        node.value = path
            .relative(destPath, fileMeta.resultAbsolutePath)
            .split('\\')
            .join('/') + fileMeta.extra;
    });
}
function processUrl(result, decl, node, opts) {
    // ignore from the css file by `!`
    if (node.value.indexOf('!') === 0) {
        node.value = node.value.slice(1);
        return Promise.resolve();
    }

    if (
        node.value.indexOf('/') === 0 ||
        node.value.indexOf('data:') === 0 ||
        node.value.indexOf('#') === 0 ||
        /^[a-z]+:\/\//.test(node.value)
    ) {
        return Promise.resolve();
    }

    /**
     * dirname of the read file css
     * @type {String}
     */
    const dirname = path.dirname(decl.source.input.file);

    let fileMeta = getFileMeta(
        dirname,
        decl.source.input.file,
        node.value,
        opts
    );

    // ignore from the fileMeta config
    if (ignore(fileMeta, opts)) {
        return Promise.resolve();
    }

    return copy(
        fileMeta.absolutePath,
        () => fileMeta.resultAbsolutePath,
        (contents, isModified) => {
            fileMeta.contents = contents;

            return Promise.resolve(
                isModified ? opts.transform(fileMeta) : fileMeta
            )
                .then(fileMetaTransformed => {
                    fileMetaTransformed.hash = opts.hashFunction(
                        fileMetaTransformed.contents
                    );
                    let tpl = opts.template;
                    if (typeof tpl === 'function') {
                        tpl = tpl(fileMetaTransformed);
                    } else {
                        tags.forEach(tag => {
                            tpl = tpl.replace(
                                '[' + tag + ']',
                                fileMetaTransformed[tag] || opts[tag] || ''
                            );
                        });
                    }

                    const resultUrl = url.parse(tpl);
                    fileMetaTransformed.resultAbsolutePath = decodeURI(
                        path.resolve(
                            opts.dest,
                            resultUrl.pathname
                        )
                    );
                    fileMetaTransformed.extra = (resultUrl.search || '') +
                        (resultUrl.hash || '');

                    return fileMetaTransformed;
                })
                .then(fileMetaTransformed => fileMetaTransformed.contents);
        }
    ).then(() => {
        const destPath = defineCSSDestPath(
            dirname,
            fileMeta.basePath,
            result,
            opts
        );

        node.value = path
            .relative(destPath, fileMeta.resultAbsolutePath)
            .split('\\')
            .join('/') + fileMeta.extra;
    });
}
function processUrl ( result , decl , node , opts ) { // ignore from the css file by `!` if ( node . value . indexOf ( '!' ) === 0 ) { node . value = node . value . slice ( 1 ) ; return Promise . resolve ( ) ; } if ( node . value . indexOf ( '/' ) === 0 || node . value . indexOf ( 'data:' ) === 0 || node . value . indexOf ( '#' ) === 0 || / ^[a-z]+:\/\/ / . test ( node . value ) ) { return Promise . resolve ( ) ; } /**
     * dirname of the read file css
     * @type {String}
     */ const dirname = path . dirname ( decl . source . input . file ) ; let fileMeta = getFileMeta ( dirname , decl . source . input . file , node . value , opts ) ; // ignore from the fileMeta config if ( ignore ( fileMeta , opts ) ) { return Promise . resolve ( ) ; } return copy ( fileMeta . absolutePath , ( ) => fileMeta . resultAbsolutePath , ( contents , isModified ) => { fileMeta . contents = contents ; return Promise . resolve ( isModified ? opts . transform ( fileMeta ) : fileMeta ) . then ( fileMetaTransformed => { fileMetaTransformed . hash = opts . hashFunction ( fileMetaTransformed . contents ) ; let tpl = opts . template ; if ( typeof tpl === 'function' ) { tpl = tpl ( fileMetaTransformed ) ; } else { tags . forEach ( tag => { tpl = tpl . replace ( '[' + tag + ']' , fileMetaTransformed [ tag ] || opts [ tag ] || '' ) ; } ) ; } const resultUrl = url . parse ( tpl ) ; fileMetaTransformed . resultAbsolutePath = decodeURI ( path . resolve ( opts . dest , resultUrl . pathname ) ) ; fileMetaTransformed . extra = ( resultUrl . search || '' ) + ( resultUrl . hash || '' ) ; return fileMetaTransformed ; } ) . then ( fileMetaTransformed => fileMetaTransformed . contents ) ; } ) . then ( ( ) => { const destPath = defineCSSDestPath ( dirname , fileMeta . basePath , result , opts ) ; node . value = path . relative ( destPath , fileMeta . resultAbsolutePath ) . split ( '\\' ) . join ( '/' ) + fileMeta . extra ; } ) ; }
process to copy an asset based on the css file, destination
and the url value

@param {Object} result
@param {Object} decl postcss declaration
@param {Object} node postcss-value-parser
@param {Object} opts plugin options
@return {Promise}
process to copy an asset based on the css file destination and the url value