You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Currently fonts are properly added to the manifest.json but you cannot see which e.g. css/vue files require this font.
This makes automatic preloading difficult as we cannot determine which file requires the font, and IF we need to require the font for the initial page load.
I suggest adding an imports key to css files within the manifest.json just like is done with JS.
This may contain imported css (which is not relevant as everything currently gets compiled to a single css file)
and fonts required by the current css or vue file.
This way when (pre)loading the css or vue file, we know we should also (pre)load those font files
Alternative
Preloading of the fonts either needs to be done manually, or ALL fonts in the manifest.json must be loaded. Which isn't ideal since likely not all fonts are actually used on the current page.
With that we can use the new fonts array to add preload tags in the html and only get fonts from that CSS file instead of all fonts from all CSS files which aren't always used. For example multisite with a CSS per store.
I've published a vite plugin that adds information about font imports to the manifest: vite-plugin-font-manifest. Working great in our use case, but would appreciate feedback if anybody wants to give it a try!
Automatic <link rel=preload> for fonts via the manifest.json Backend Integration already works in Vite v7.1.12, as long as there is some JavaScript entry point that includes the CSS entry point via import statement.
I think it should be a bug. The "assets" manifest.json property should not behave differently depending if there happens to be some other JavaScript entry point or not.
For the specific use case where I stumbled over this issue, I was able to just combine the CSS and JavaScript entry points as they were always used together.
Hi! I’d like to work on this issue.
I’ll reproduce the problem with a minimal setup and explore how we can expose CSS → font dependencies in manifest.json.
If maintainers have any guidance on where this metadata should live, please let me know. Thanks!
Hi! I’m interested in taking this issue.
I’ll create a small repro and check how fonts are attached to CSS assets during the build. Then I’ll experiment with adding an imports-like field to CSS entries in the manifest.
Any suggestions before I start are welcome.
Activity
royduin commentedon Oct 18, 2024
An example, currently the Vite just adds all the fonts with no relation to the css file where the font was discovered in the manifest:
Where Javascript files do have a reference with dynamic imports:
It would be nice to have something like:
With that we can use the new fonts array to add preload tags in the html and only get fonts from that CSS file instead of all fonts from all CSS files which aren't always used. For example multisite with a CSS per store.
bolt-new-by-stackblitz commentedon Oct 19, 2024
indykoning commentedon Dec 3, 2024
I'm guessing somewhere here we need to have access to the bundle so we can set the
bundle.importsto the files we find herevite/packages/vite/src/node/plugins/css.ts
Line 643 in ccee3d7
daun commentedon Jun 16, 2025
I've published a vite plugin that adds information about font imports to the manifest: vite-plugin-font-manifest. Working great in our use case, but would appreciate feedback if anybody wants to give it a try!
{ "src/fonts/Inter-Regular.woff2": { "file": "assets/Inter-Regular-CnZ_CWUo.woff2", "src": "src/fonts/Inter-Regular.woff2", "fontFace": { "family": "Inter", "weight": "400", "style": "normal", "mime": "font/woff2", "css": "@font-face { /* */ }", "definedIn": ["src/css/display.css"] } }, "src/css/display.css": { "fonts": ["src/fonts/Inter-Regular.woff2"] } }adamkoppede commentedon Oct 27, 2025
Automatic
<link rel=preload>for fonts via the manifest.json Backend Integration already works in Vite v7.1.12, as long as there is some JavaScript entry point that includes the CSS entry point viaimportstatement.I think it should be a bug. The "assets" manifest.json property should not behave differently depending if there happens to be some other JavaScript entry point or not.
For the specific use case where I stumbled over this issue, I was able to just combine the CSS and JavaScript entry points as they were always used together.
In details, the following works in v7.1.12:
The resulting `manifest.json` contains the "assets" key for the CSS entry point:
{ "font.woff2": { "file": "assets/font-BRpGEcXM.woff2", "src": "font.woff2" }, "test.css": { "file": "assets/test-Bz9E2gFy.js", "name": "test", "src": "test.css", "isEntry": true, "css": [ "assets/test-BQohd8LT.css" ], "assets": [ "assets/font-BRpGEcXM.woff2" ] }, "test.js": { "file": "assets/test-C4i5TFBK.js", "name": "test", "src": "test.js", "isEntry": true, "imports": [ "test.css" ] } }If the JavaScript entry point is missing:
The "asset" key will not be set on the CSS entry point in the generated `manifest.json`:
{ "font.woff2": { "file": "assets/font-BRpGEcXM.woff2", "src": "font.woff2" }, "test.css": { "file": "assets/test-BQohd8LT.css", "src": "test.css", "isEntry": true, "names": [ "test.css" ] } }If only the JavaScript entry point is specified,
no empty JavaScript dist file will be generated for the CSS file:
{ "font.woff2": { "file": "assets/font-BRpGEcXM.woff2", "src": "font.woff2" }, "test.js": { "file": "assets/test-Bz9E2gFy.js", "name": "test", "src": "test.js", "isEntry": true, "css": [ "assets/test-BQohd8LT.css" ], "assets": [ "assets/font-BRpGEcXM.woff2" ] } }fix(manifest): "assets" missing for standalone CSS entry points
aparajitaks commentedon Nov 29, 2025
Hi! I’d like to work on this issue.
I’ll reproduce the problem with a minimal setup and explore how we can expose CSS → font dependencies in manifest.json.
If maintainers have any guidance on where this metadata should live, please let me know. Thanks!
RudraKo commentedon Nov 29, 2025
Hi! I’m interested in taking this issue.
I’ll create a small repro and check how fonts are attached to CSS assets during the build. Then I’ll experiment with adding an imports-like field to CSS entries in the manifest.
Any suggestions before I start are welcome.