async function rebaseAssets(css, from, to, options = {}) {
  const {method = 'rebase', strict = false, inlined = false} = options;
  let rebased = css.toString();

  debug('Rebase assets', {from, to});

  if (/\/$/.test(to)) {
    to += 'temp.html';
  }

  if (/\/$/.test(from)) {
    from += 'temp.css';
  }

  if (isRemote(from)) {
    const {pathname} = urlParse(from);
    from = pathname;
  }

  try {
    if (typeof method === 'function') {
      const transform = (asset, ...rest) => {
        const assetNormalized = {
          ...asset,
          absolutePath: normalizePath(asset.absolutePath),
          relativePath: normalizePath(asset.relativePath),
        };

        return method(assetNormalized, ...rest);
      };

      const result = await postcss()
        .use(postcssUrl({url: transform}))
        .process(css, {from, to});
      rebased = result.css;
    } else if (from && to) {
      const result = await postcss()
        .use(postcssUrl({url: method}))
        .process(css, {from, to});
      rebased = result.css;
    }
  } catch (error) {
    if (strict) {
      if (inlined) {
        error.message = error.message.replace(from, 'Inlined stylesheet');
      }

      throw error;
    }

    debug(`CSS parse error: ${error.message}`);
    rebased = '';
  }

  return Buffer.from(rebased);
}
Rebase image url in css

@param {Buffer|string} css Stylesheet
@param {string} from Rebase from url
@param {string} to Rebase to url
@param {opject} options
   method: {string|function} method Rebase method. See https://github.com/postcss/postcss-url#options-combinations
   strict: fail on invalid css
   inlined: boolean flag indicating inlined css
@param {boolean} strict fail on invalid css
@returns {Buffer} Rebased css