question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

@font-face and relative path

See original GitHub issue

Hi 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:closed
  • Created 7 years ago
  • Comments:5 (3 by maintainers)

github_iconTop GitHub Comments

6reactions
jhnnscommented, Mar 16, 2017

Have you read the section about problems with url()? Please also note that the README expects webpack 2.

2reactions
MontageDcommented, Oct 2, 2018

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 ; as module:{ { test: /\.(woff|woff2|eot|ttf|otf)$/, use: [ 'file-loader' ] } }

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found