Skip to content

Webpack: not loading font-awesome fonts #7611

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

Closed
codeepic opened this issue Sep 6, 2017 · 5 comments
Closed

Webpack: not loading font-awesome fonts #7611

codeepic opened this issue Sep 6, 2017 · 5 comments

Comments

@codeepic
Copy link

codeepic commented Sep 6, 2017

Bug Report or Feature Request (mark with an x)

- [x ] bug report -> please search issues before submitting
- [ ] feature request

Versions.

@angular/cli: 1.2.5
node: 7.10.0
os: win32 x64

Related to #1463

I tried method mentioned by @omobono and @shri3k:

$fa-font-path: "~font-awesome/font";
@import "~font-awesome/scss/font-awesome";

and variations of it but it still doesn't work. After I build the project, I get 404 for the fonts. No matter what I put as $fa-font-path, they are being served from the root of the project.

@Chelayos
Copy link

Chelayos commented Sep 7, 2017

working for me, tried this today in one of our business apps. (@angular4.3.6)

in my case it loads the font stuff from the same folder i specified for font-awesome.min.css

angular-cli.json

 "styles": [
"node_modules/font-awesome/css/font-awesome.min.css"
]

@codeepic
Copy link
Author

codeepic commented Sep 27, 2017

In my case all the fonts are loaded into dist folder, but the css points to the wrong directory.

font-awesome-fonts-not-loading

So if you have a look in the above screenshot, on the left in the source for the application, the root folder location is '/assets/accounts/dist' but if you look at the 404 error messages on the right, the CSS tries to looks for the fonts in the wrong place - not in the '/assets/accounts/dist'.

@elvinmeza
Copy link

I was facing the same issue, turns out a slash was missing for the base-ref parameter, at its end. Fixed it running the build command like this: ng build --base-href /myapp/ --deploy-url /myapp/

@codeepic
Copy link
Author

codeepic commented Sep 28, 2017

@elvinmeza - yes, that fixes my problem.
Big thanks to @filipesilva for pointing me in the right direction.

How we resolved the issue.

I have the Angular 2 app running with Scala Play framework.
Front-end of the Play app is held in 'accounts' folder.

Hence in my 'accounts.scala.html' I have <base href="/accounts" />

Play framework serves all the static assets from '/assets/accounts/dist/' folder.

When you run ng build the Angular-CLI will deploy all the files into 'dist' folder and the url paths in the css will also point to the dist folder - which is fine in most scenarios.

But when you open Play app in the browser, there is no directory like 'localhost/dist', so I was getting 404 for all fonts.

After I run ng build --deploy-url /assets/accounts/dist/
all the files including fonts are still output to the dist folder, but the --deploy-url flag changes the relative paths for all the assets that get referenced in css.
So now the url for the fonts in css stylesheet is: '/assets/accounts/dist/font-awesome.ttf';

@angular-automatic-lock-bot
Copy link

This issue has been automatically locked due to inactivity.
Please file a new issue if you are encountering a similar or related problem.

Read more about our automatic conversation locking policy.

This action has been performed automatically by a bot.

@angular-automatic-lock-bot angular-automatic-lock-bot bot locked and limited conversation to collaborators Sep 7, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

4 participants