Comments (4)
I encountered the same issue.
I don't understand why the default export doesn't work, but using the named export worked for me:
import { VitePluginFonts } from 'vite-plugin-fonts'
export default {
plugins: [
VitePluginFonts({
google: {
families: ['Source Sans Pro'],
},
}),
],
}
from unplugin-fonts.
From looking at the
index.ts
,VitePluginFonts
is exported as the default and ViteFonts isn't exported at all (see below).
Hum, that's wired, the default export should work, maybe it's related to https://www.typescriptlang.org/tsconfig#allowSyntheticDefaultImports
Updating the examples to reflect the right import should address the issue and I don't mind doing it/submitting a PR. For the maintainers, if you would prefer I don't or want to handle it differently, just let me know!
I updated the readme to use the named export, which should work in any cases!
Thanks for the feedback!
from unplugin-fonts.
Experienced the same and as @haunted-loaf mentioned, using VitePluginFonts
as a named import worked.
From looking at the index.ts
, VitePluginFonts
is exported as the default and ViteFonts isn't exported at all (see below).
export {
VitePluginFonts,
VitePluginFontsOptions,
}
export default VitePluginFonts
However, the examples in the README all import and make use of ViteFonts
, such as in the below.
Updating the examples to reflect the right import should address the issue and I don't mind doing it/submitting a PR. For the maintainers, if you would prefer I don't or want to handle it differently, just let me know!
from unplugin-fonts.
Ah, that's a good catch and may be the issue because you're right, for the default export it shouldn't really matter what you call it when importing it, so long as its being exported. Thinking about it, I think its less of a matter of there not being a default and more that it's not being interpreted/identifiable as a function. I'm not sure why that's the case, but it may have to do with when and/or how the type definitions are being generated via dts
when the plugin is built.
Thanks for being so responsive and in case it helps, this is what index.d.ts
looks like in dist after build:
declare function VitePluginFonts(options?: VitePluginFontsOptions): Plugin;
export { VitePluginFonts, VitePluginFontsOptions, VitePluginFonts as default };
from unplugin-fonts.
Related Issues (20)
- Option HtmlTagDescriptor injectTo
- Feature: Adding possibility to choose unicode range HOT 1
- support vite 3
- Multiple custom fonts from same family HOT 4
- Support: How to deal with installed fonts such as fontsource/roboto HOT 1
- How can Inject Google font in Nuxt3? HOT 1
- Support for additional option in custom font specification
- Dont work in dev mode HOT 7
- ERR_REQUIRE_ESM with Vite 3.1.5 HOT 1
- Fonts for nested routes are not loaded properly HOT 2
- Using with typescript HOT 1
- Support weight prefixed local fonts HOT 2
- Error on start: TypeError: VitePluginFonts is not a function HOT 2
- files in the public directory are served at the root path. HOT 2
- [Bug]: Font not loading in Sveltekit HOT 3
- Is this tool downloads fonts? HOT 3
- [Bug]: Not working after switch from vite-plugin-fonts HOT 6
- [Bug]: Type custom did not generate @font-face HOT 3
- [Bug]: Unfonts not callable HOT 2
- [Bug]: SvelteKit example doesn't build HOT 3
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from unplugin-fonts.