@font-face and relative path
See original GitHub issueHi community,
I would like use relative path with in my scss file, but webpack return an error in my console :
ERROR in ./~/css-loader!./~/sass-loader!./private/scss/app.scss
Module not found: Error: Cannot resolve 'file' or 'directory' ./public/assets/fonts/titillium-web/titillium-web-bold.woff2 in D:\Sites\dcns\private\scss
@ ./~/css-loader!./~/sass-loader!./private/scss/app.scss 6:5635-5706
My config :
{
test: /\.scss$/,
loaders: ['style', 'css', 'sass']
},
{
test: /\.(eot|svg|ttf|woff|woff2)$/,
loader: 'file?name=public/fonts/[name].[ext]'
},
{
test: /\.(png|woff|woff2|eot|ttf|svg)$/,
loader: 'url-loader?limit=100000'
}
And my scss file :
@font-face {
font-family: 'Titillium Web';
font-style: normal;
font-weight: 300;
src:
url(fonts/titillium-web/titillium-web-light.woff) format('woff'),
url(fonts/titillium-web/titillium-web-light.woff2) format('woff2');
}
Anyone can help me ?
Thank you !
Issue Analytics
- State:
- Created 7 years ago
- Comments:5 (3 by maintainers)
Top Results From Across the Web
relative file path to fonts in css file - Stack Overflow
When I put the above @font-face CSS in the page above where the icons are being shown it works but when I put...
Read more >Relative path in css for @font-face embedding - Google Groups
I'm trying to use an embedded font referenced in a stylesheet. The only url that seems to work in the @font-face declaration (in...
Read more >Get Help - Codecademy Forums
I want to know about how the relative path works like . ... For example, in CSS Typography - Font-Face III, we are...
Read more >src - CSS: Cascading Style Sheets - MDN Web Docs
As with other URLs in CSS, the URL may be relative, in which case it is resolved relative to the location of the...
Read more >Problem with Path in @font-face src: url(...) - General Support
Normally I would do the same, but in this case I need to output the font-face in the <head> section. I assume a...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Have you read the section about problems with
url()
? Please also note that the README expects webpack 2.You can try this way in the latest webpack .
src: font-url(fonts/titillium-web/titillium-web-light.woff) format('woff'), font-url(fonts/titillium-web/titillium-web-light.woff2) format('woff2');
But the premise is if your configuration is well ; asmodule:{ { test: /\.(woff|woff2|eot|ttf|otf)$/, use: [ 'file-loader' ] } }