Repository navigation
docs: show a reliable way to preload fonts - #16424
Conversation
|
Install the latest version of pnpm add https://pkg.svelte.dev/@sveltejs/kit/c/d31aec37ee04e7757aac488d3880f6dccab711a2Open in Note This PR is from a fork. A maintainer must approve approve each commit before it can be built and installed. |
|
71aaa0d to
80a6abe
Compare
|
Hmm. I wonder if we should provide a |
|
Agreed, that would remove both footguns this recipe works around. Deriving it from the path mostly works, though there are edge cases I found: dotted basenames like I think I can implement this. I'm very supportive of this. Happy to make a separate PR and fix this one for docs. |
80a6abe to
24c920b
Compare
24c920b to
a79a518
Compare
…16443) Implements the `name` property from #16424 (comment). `name` is looked up from the Vite client manifest where the fonts arrays are built, so the filter receives the exact source file name. Deriving it from the emitted path was wrong two ways, the bundler sanitizes characters (`inter+bold.woff2` is emitted as `inter_bold.<hash>.woff2`) and content-identical assets are emitted once under a single name. The union includes `name` for `font` only, kit never calls `preload` with type `asset`. --- ### Please don't delete this checklist! Before submitting the PR, please make sure you do the following: - [x] It's really useful if your PR references an issue where it is discussed ahead of time. In many cases, features are absent for a reason. For large changes, please create an RFC: https://github.com/sveltejs/rfcs - [x] This message body should clearly illustrate what problems it solves. - [x] Ideally, include a test that fails without this PR but passes with it. ### Tests - [x] Run the tests with `pnpm test` and lint the project with `pnpm lint` and `pnpm check` ### Changesets - [x] If your PR makes a change that should be noted in one or more packages' changelogs, generate a changeset by running `pnpm changeset` and following the prompts. Changesets that add features should be `minor` and those that fix bugs should be `patch`. Please prefix changeset messages with `feat:`, `fix:`, or `chore:`. ### Edits - [x] Please ensure that 'Allow edits from maintainers' is checked. PRs without this option may be closed. --------- Co-authored-by: Rich Harris <rich.harris@vercel.com>
The docs say to opt fonts into preloading with a
preloadfilter but not what to match against, so what everyone writes is a substring check against the hashed output path, which silently stops matching when the font is renamed. #16443 addedfilenamefor this; this shows it.Please don't delete this checklist! Before submitting the PR, please make sure you do the following:
Tests
pnpm testand lint the project withpnpm lintandpnpm checkChangesets
pnpm changesetand following the prompts. Changesets that add features should beminorand those that fix bugs should bepatch. Please prefix changeset messages withfeat:,fix:, orchore:.Edits