Closed Tragio closed 3 years ago
Hi :)
It should work via the static alias.
https://nuxtjs.org/docs/2.x/configuration-glossary/configuration-alias
{
fileExtensions: ['woff2', 'woff'],
fontFamily: 'Roboto Slab',
fontFaces: [
{
preload: true,
src: 'static/fonts/roboto-slab-v11-latin/roboto-slab-v11-latin-regular',
fontWeight: 400,
fontStyle: 'normal'
},
{
preload: true,
src: 'static/fonts/roboto-slab-v11-latin/roboto-slab-v11-latin-700',
fontWeight: 700,
fontStyle: 'normal'
}
]
}
@ThornWalli thank you for your reply. Yes, I'm using it in that way but it is not working. 🤔
https://domain.com/static/assets/fonts/montserrat-v14-latin-regular.woff - Failed to load resource: the server responded with a status of 404 ()
[
'nuxt-font-loader-strategy',
{
fonts: [
{
fontFamily: 'Montserrat',
fontFaces: [
{
preload: true,
localSrc: ['Montserrat Regular', 'Montserrat-Regular'],
src: 'static/assets/fonts/montserrat-v14-latin-regular',
fontWeight: 400,
fontStyle: 'normal',
fontDisplay: 'fallback',
},
],
},
],
},
],
Is the Assets folder in the Static directory?
@ThornWalli yes, it is, for a second my brain frozen 😅
@Tragio You can try it again.
Now absolute paths should also work. Important the "/" ;)
I just noticed something else, the router base information from the router is missing in this case.
This would have to be added in the module.
Push in an update again.
https://github.com/GrabarzUndPartner/nuxt-font-loader-strategy/pull/157
@ThornWalli thank you for your beautiful work. It's working if I open the homepage but if I open in the /blog/ it tries to use that path.
https://domain.com/blog/assets/fonts/montserrat-v14-latin-regular.woff2
@Tragio The base path was missing in the CSS. Should work now.
@ThornWalli thank you very much for all the effort and work. All is working great now 😄
Hello!
Thank you very much for this plugin and all the work.
If we use
'@/assets/fonts/font-a-regular'
as stated in the documentation, it will be hashed in each build. This means that it will never be cached properly. Fonts rarely change, and if they change we can easily update their filename.To avoid this, the fonts should be located in the
/static/
folder. However, when I use for example this pathsrc: '/static/assets/fonts/montserrat-v14-latin-700'
the plugin does not work properly as it can't locate and preload the plugin.Would be possible to check this?
Thank you once again and have a great year!