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

Importing a CSS into JS leaves __VITE_ASSET__ in the JS file in a production build #5599

Closed
7 tasks done
Artur- opened this issue Nov 9, 2021 · 0 comments · Fixed by #5729
Closed
7 tasks done

Importing a CSS into JS leaves __VITE_ASSET__ in the JS file in a production build #5599

Artur- opened this issue Nov 9, 2021 · 0 comments · Fixed by #5729

Comments

@Artur-
Copy link
Contributor

Artur- commented Nov 9, 2021

Describe the bug

When importing CSS like

import styles from  './style.css?inline'

then assets like

@font-face {
  src: url("../fonts/la-solid-900.eot");

are extracted to files and the original URL is replaced by __VITE_ASSET_<hash>__. In CSS files this seems to be replaced to the proper asset during build but in JS files, the tag remains in the final bundle.

The font face then obviously does not work.

Reproduction

git clone https://github.com/Artur-/vite-vaadin-problem4
cd vite-vaadin-problem4
npm i 
npm run build
grep __VITE_ASSET_ -R dist

System Info

System:
    OS: macOS 11.6
    CPU: (12) x64 Intel(R) Core(TM) i7-9750H CPU @ 2.60GHz
    Memory: 225.25 MB / 32.00 GB
    Shell: 3.2.57 - /bin/bash
  Binaries:
    Node: 16.13.0 - ~/.nvm/versions/node/v16.13.0/bin/node
    Yarn: 1.22.11 - /usr/local/bin/yarn
    npm: 8.1.0 - ~/.nvm/versions/node/v16.13.0/bin/npm
    Watchman: 2021.10.04.00 - /usr/local/bin/watchman
  Browsers:
    Brave Browser: 93.1.29.81
    Chrome: 95.0.4638.69
    Chrome Canary: 98.0.4696.0
    Firefox: 93.0
    Safari: 15.1
    Safari Technology Preview: 15.4
  npmPackages:
    vite: ^2.6.4 => 2.6.13

Used Package Manager

npm

Logs

No response

Validations

@Artur- Artur- changed the title Importing a CSS into JS leaves __VITE_ASSET__ in the CSS file in a production build Importing a CSS into JS leaves __VITE_ASSET__ in the JS file in a production build Nov 9, 2021
Artur- added a commit to Artur-/vite that referenced this issue Nov 17, 2021
Artur- added a commit to Artur-/vite that referenced this issue Nov 18, 2021
Artur- added a commit to Artur-/vite that referenced this issue Nov 18, 2021
Artur- added a commit to Artur-/vite that referenced this issue Nov 18, 2021
Artur- added a commit to Artur-/vite that referenced this issue Nov 18, 2021
@github-actions github-actions bot locked and limited conversation to collaborators Dec 7, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant