Can't resolve absolute paths when prefixed with `~` in scss files

Open
#176 1 comment 3 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Assessment

Difficulty
3/5
Estimated time
1-2 days
Newbie friendliness
25/100
Issue type
Bug
Clarity
Needs clarification
Activity status
Stale
Tech stack
javascript
Domain
tooling

Research direction

Reproduce the issue with the shown SCSS @font-face block and inspect postcss-url's URL resolution entry point. The work is done when a ~font-awesome path resolves from node_modules rather than relative to the SCSS file and asset inlining works.

Written by the indexing model from the issue text.

Description

I have a font-face block as follows:

@font-face {
  font-family: 'FontAwesome';
  src: url('~font-awesome/fonts/fontawesome-webfont.eot?v=4.7.0');
  src: url('~font-awesome/fonts/fontawesome-webfont.eot?#iefix&v=4.7.0') format('embedded-opentype');
  font-weight: normal;
  font-style: normal;
}

postcss-url can't seem to resolve ~font-awesome/fonts/fontawesome-webfont.eot to the correct node_modules path and resolves it relative to the scss file that's being transformed i.e. /Users/me/my-project/src/~font-awesome/fonts/fontawesome-webfont.eot which causes inlining to not work since there's no font file at that path.

Is there a way to have postcss-url resolve ~ prefixed paths from node_modules instead of relative to the scss file?

Dominant language
JavaScript
Stars
383
Forks
58
PR merge metrics
No merged PRs in 30d

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from postcss/postcss-url

All issues in postcss/postcss-url

Similar issues

More JavaScript issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.