icons: Icon font regression when using Vite

Hello!

I have been using icon font in Vite by simpley including 1 line in my SCSS file:

@import 'bootstrap-icons/font/bootstrap-icons';

After updating to 1.9, this is no longer working. I assume it is related to changes of font-path variables, hashes, etc. - as mentioned in #1378.

It would be super-cool to keep this compatibility.

About this issue

  • Original URL
  • State: closed
  • Created 4 years ago
  • Comments: 18 (3 by maintainers)

Commits related to this issue

Most upvoted comments

I am still seeing the same erratic behavior, even after upgrading to 1.10.5

Can confirm this is still an issue regarding the latest versions. Using Vite and SASS, @import "~bootstrap-icons/font/bootstrap-icons"; which includes the SASS version, does in fact break. Workaround as mentioned, @import "~bootstrap-icons/font/bootstrap-icons.css"; does fix the issue.

Very likely, this is related to https://github.com/vitejs/vite/issues/7651 - Vite SASS processor is unable to peoperly rebase url() when there are variables in it (if I understand correctly).

So move from (1.8.3):

$bootstrap-icons-font-src: url("./fonts/bootstrap-icons.woff2?08efbba7c53d8c5413793eecb19b20bb") format("woff2"),
url("./fonts/bootstrap-icons.woff?08efbba7c53d8c5413793eecb19b20bb") format("woff") !default;

to (1.9)

$bootstrap-icons-font-src: url("#{$bootstrap-icons-font-file}.woff2?#{$bootstrap-icons-font-hash}") format("woff2"), url("#{$bo
otstrap-icons-font-file}.woff?#{$bootstrap-icons-font-hash}") format("woff") !default;

killed the Vite importer.

As a workaround, we can import the generated CSS like this:

@import 'bootstrap-icons/font/bootstrap-icons.css';

It skips SASS and in plain CSS the url() rebasing apparently works…

This should be fixed in main and will be in v1.10.4.

I know this is old, so not meaning to necro, but Vite 4.x changed the default charset to UTF-8 and recommends people ensure they’re using the correct Content-Type header when serving CSS, as well as having your index.html include the <meta charset="utf-8 /> tag in your <head>, which should be default for Vite users anyway.

Thread: https://github.com/vitejs/vite/issues/13676#issuecomment-1612688039

I suppose even adding @import 'bootstrap-icons/font/bootstrap-icons.css'; should be covered in the official usage documentation for people using Vite.

parcel.js is failing in similar way too: https://github.com/parcel-bundler/parcel/issues/6285 except that the .css workaround doesn’t seem to work