Webpack Import Including Font Face with Relative Path

Viewed 1809

In my Webpack configuration I'm defining one resource root for common files like this:

{
  loader: 'sass-loader',
  options: {
    includePaths: [
      'node_modules',
      'src/components/_common'
    ]
  }
}

Now I'm having e.g. a file _fonts.scss in the resource root and can import it using @import "fonts";. This is working like a charm.

However, if this file contains a @font-face directive that is written relative to src/components/_common (path like in the Webpack configuration above) the file loading of that font url won't work. Webpack isn't able to resolve this URL as it assumes that it's written based on the path of the actual file which imports _fonts.scss, which is not src/components/_common.

So, my question is: Would it be possible that I write the path absolute from the beginning of the project, so that Webpack can always resolve it as it's no longer relative? I've tried it with no luck. Also I've tried specifying resolve.modules and resolve.alias with no luck too.

1 Answers
Related