function getStylesheetPath(document, file, options = {}) {
  let {base} = options;

  // Check inline styles
  if (file.inline) {
    return normalizePath(`${document.virtualPath}.css`);
  }

  // Check remote
  if (file.remote) {
    return getRemoteStylesheetPath(file.urlObj, document.urlObj);
  }

  // Generate path relative to document if stylesheet is referenced relative
  //
  if (isRelative(file.path) && document.virtualPath) {
    return normalizePath(joinPath(path.dirname(document.virtualPath), file.path));
  }

  if (base && path.resolve(file.path).includes(path.resolve(base))) {
    base = path.resolve(base);
    return normalizePath(`/${path.relative(path.resolve(base), path.resolve(file.path))}`);
  }

  // Try to compute path based on document link tags with same name
  const stylesheet = document.stylesheets
    .filter((href) => !Buffer.isBuffer(href))
    .find((href) => {
      const {pathname} = urlParse(href);
      const name = path.basename(pathname);
      return name === path.basename(file.path);
    });

  if (stylesheet && isRelative(stylesheet) && document.virtualPath) {
    return normalizePath(joinPath(path.dirname(document.virtualPath), stylesheet));
  }

  if (stylesheet && isRemote(stylesheet)) {
    return getRemoteStylesheetPath(urlParse(stylesheet), document.urlObj);
  }

  if (stylesheet) {
    return stylesheet;
  }

  // Try to find stylesheet path based on document link tags
  const [unsafestylesheet] = document.stylesheets
    .filter((href) => !Buffer.isBuffer(href))
    .sort((a) => (isRemote(a) ? 1 : -1));
  if (unsafestylesheet && isRelative(unsafestylesheet) && document.virtualPath) {
    return normalizePath(
      joinPath(path.dirname(document.virtualPath), joinPath(path.dirname(unsafestylesheet), path.basename(file.path)))
    );
  }

  if (unsafestylesheet && isRemote(unsafestylesheet)) {
    return getRemoteStylesheetPath(urlParse(unsafestylesheet), document.urlObj, path.basename(file.path));
  }

  if (stylesheet) {
    return stylesheet;
  }

  process.stderr.write(BASE_WARNING);
  if (document.virtualPath && file.path) {
    return normalizePath(joinPath(path.dirname(document.virtualPath), path.basename(file.path)));
  }

  return '';
}
Get path to stylesheet based on docroot
@param {Vinyl} document Optional reference document
@param {Vinyl} file the file we want to check
@param {object} options Critical options object
@returns {Promise<string>} Computed path