-
I need to load a custom webfont (not coming from Google or any other CDN) into a Tailpress project. I currently added the @font-face declarations in the custom.css file and the actual woff and woff2 files into the resources directory. When the Laravel Mix build is run, I can see that the woff and woff2 files are correctly placed in a fonts directory in the theme's root. The issue however comes up as the generated app.css file is trying to load the font files from the project's root directory (/fonts/) and not the theme directory (/wp-content/themes/theme/fonts/). What is the best way to go about this, please? Since the @font-face src URL will never match whatever is generated in the app.css - as far as I know at least. Thanks! |
Beta Was this translation helpful? Give feedback.
Replies: 3 comments 8 replies
-
Here is an example with custom fonts: https://github.com/jeffreyvr/tailpress-custom-font-example Things to do:
|
Beta Was this translation helpful? Give feedback.
-
Just a quick note on this: the source root is now set by default in version 1.0.0. |
Beta Was this translation helpful? Give feedback.
-
@jeffreyvr Is there an easy way to get font awesome to work via npm without having to manually copy over the font files? |
Beta Was this translation helpful? Give feedback.
Here is an example with custom fonts:
https://github.com/jeffreyvr/tailpress-custom-font-example
Things to do:
Set the source root (this will prevent 404’s):
https://github.com/jeffreyvr/tailpress-custom-font-example/blob/master/webpack.mix.js#L4
Add your fonts in the fonts folder within ‘resources’:
https://github.com/jeffreyvr/tailpress-custom-font-example/tree/master/resources
Add the needed font-face’s in the CSS:
https://github.com/jeffreyvr/tailpress-custom-font-example/blob/master/resources/css/app.css
Define your custom font within the Tailwind config file:
https://github.com/jeffreyvr/tailpress-custom-font-example/blob/master/tailwind.config.js#L26