Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Relative URL import in imported scss file is not rebased #12515

Closed
7 tasks done
C-Higgins opened this issue Mar 21, 2023 · 2 comments
Closed
7 tasks done

Relative URL import in imported scss file is not rebased #12515

C-Higgins opened this issue Mar 21, 2023 · 2 comments
Labels
duplicate This issue or pull request already exists

Comments

@C-Higgins
Copy link

Describe the bug

In my app:
@import 'package/src/scss/main.scss';

In package/src/scss/main.scss:
@import 'fonts.scss';

In package/src/scss/fonts.scss:

@font-face {
  font-family: "myfont";
  src: url('../fonts/font.ttf');
}

The font file is in node_modules/package/src/fonts/font.ttf, so within the package, this import is correct.
However, Vite then tries to fetch the font file at localhost:5173/fonts/font.ttf and gets a 404.

Reproduction

https://stackblitz.com/edit/vitejs-vite-25cpaq?file=nm/src/scss/fonts.scss

Steps to reproduce

No response

System Info

System:
    OS: macOS 13.2.1
    CPU: (10) arm64 Apple M1 Pro
    Memory: 805.00 MB / 16.00 GB
    Shell: 5.8.1 - /bin/zsh
  Binaries:
    Node: 16.16.0 - ~/.asdf/installs/nodejs/16.16.0/bin/node
    Yarn: 1.22.19 - ~/.asdf/installs/nodejs/16.16.0/bin/yarn
    npm: 8.11.0 - ~/.asdf/plugins/nodejs/shims/npm
  Browsers:
    Firefox: 111.0
    Safari: 16.3
  npmPackages:
    @vitejs/plugin-react-swc: ^3.2.0 => 3.2.0 
    vite: ^4.2.0 => 4.2.0

Used Package Manager

yarn

Logs

Notice in console of repro link:

downloadable font: download failed (font-family: "myfont" ... source: https://vitejsvite25cpaq-orzw--5173.local-corp.webcontainer.io/fonts/font.ttf 

The URL should not be /fonts/font.ttf

Validations

@stackblitz
Copy link

stackblitz bot commented Mar 21, 2023

Fix this issue in StackBlitz Codeflow Start a new pull request in StackBlitz Codeflow.

@sapphi-red
Copy link
Member

Duplicate of #11012

@sapphi-red sapphi-red marked this as a duplicate of #11012 Mar 21, 2023
@sapphi-red sapphi-red closed this as not planned Won't fix, can't repro, duplicate, stale Mar 21, 2023
@sapphi-red sapphi-red added duplicate This issue or pull request already exists and removed pending triage labels Mar 21, 2023
@github-actions github-actions bot locked and limited conversation to collaborators Apr 5, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
duplicate This issue or pull request already exists
Projects
None yet
Development

No branches or pull requests

2 participants