-
Notifications
You must be signed in to change notification settings - Fork 12k
SCSS "Module not found: Error: Can't resolve" for @font-face url with relative path #5213
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
I've created an example repository for this issue: https://github.com/JSMike/angular-cli-issue-5213 The result is:
|
Hm I'm looking at your example repo and as far as I can tell what's happening is that the font is always being resolved relative to the initial entry point ( So if I change it This looks like a bug somewhere really. |
Searched around and apparently this is just how sass loader works: sass/sass#1015 There's a suggestion for using https://github.com/bholloway/resolve-url-loader, but it does have the serious limitation of not working without sourcemaps. This is a big problem because component css doesn't support sourcemaps at all, and your project shouldn't die just because sourcemaps aren't there. So I think the recommended approach here is to put these font files in the assets folder, and use absolute paths (starting with
If anyone has a better way I'm happy to hear it. |
My solution for now was to create |
I'm closing it as 'working as intended' as per sass then. |
It seems to me this does not "work as intended". You need to provide a way for libraries with relative scss imports to work, given that webpack projects can do this. Otherwise we have to try hack a workaround, ditch the scss library or remove angular-cli. |
In fresh app when I ran
But after that I switch finally to yarn and it working like charm :) |
@jigneshkhokhani your issue is unrelated to this item. Please look for a similar issue or create a new one. |
@this is still not working for me. I serve my app from a subdirectory, as in
So I am stuck. I tried moving the |
If you're using the CLI then webpack will take care of the font bundling, it doesn't need to be in assets. Your CSS file |
@filipesilva you are right, but thing is while deploy code on server it is again showing "no module found" so i have tried using |
I met the same problem but not on local anymore, it happened at server. In scss file, if I followed the same instructions as @filipesilva it worked normally on local. But when I used the |
@thovo the file with the |
Without Modifying Webpack Config, This work:
|
@justgeek works great, thank you. |
Maybe I'm confused, but importing as raw css does not solve the problem for anyone who wants to import an external stylesheet as a sass file so that they can |
@ShawnMercado same here. I bought one Theme, that is used as npm module, and has lots of xxx/xxx.png paths. All those give me errors, and CLI is useless. Copying something doesn't help, as I have rename all URL paths to absolutes. If I do that I will have problems with updating my theme. This is big problem. |
I spent a day of painful researches and still has this issue. I tried every workaround in this topic and also read On local machine (OS X 10.13.3) all works fine, but on gitlab runner (ubuntu image) command
also try
also try to switch from scss to css and import it How can I solve this? |
@EugeneSnihovsky Same issue here. |
same issue... |
same issue |
Hi, Just use url ('/assets/ instead of url('/assets/ Give a blank between url and ( |
@hemregeris, I had the same issue in a non angular related project using webpack, and this seems to work. |
This issue has been automatically locked due to inactivity. Read more about our automatic conversation locking policy. This action has been performed automatically by a bot. |
OS?
Versions.
@angular/cli: 1.0.0-rc.1
node: 6.9.4
os: linux x64
Repro steps.
Importing a font with sass using relative path:
The log given by the failure.
Mention any other details that might be useful.
Looks like this may be related to #4778
From my understanding relatives paths in url() was fixed for
@import
, maybe something additional needs to be done for@font-face
Also, this error doesn't occur when using the absolute path starting from src/, the error only appears when using the relative path.
The text was updated successfully, but these errors were encountered: