"Font Awesome icons are only visible online on the -dev website, not visible anywhere

I followed the recommended steps on Fontawesome's official site to install the fontawesome library. I used the following command:

npm install --save-dev @fortawesome/fontawesome-free

For production purposes, I included the following code in my index.html file:

<link rel="stylesheet" href="https://use.fontawesome.com/releases/v5.8.0/css/all.css">

When running ng serve, the icons do not display when offline.

To make sure the icons show up offline as well, I imported the all.css file into my style.css like this:

@import "../node_modules/@fortawesome/fontawesome-free/css/all.css";

Running ng build --prod displays the icons fine when online, but how can I see them when using ng serve and offline?

Here is a snippet of my package.json:

{
  "name": "test-app",
  "version": "0.0.1",
  "scripts": {
    "ng": "ng",
    "start": "ng serve",
    "build": "ng build"
  },
  "private": true,
  "dependencies": {
    "@angular/animations": "^7.2.5",
    ...
  },
  "devDependencies": {
    "@angular-devkit/build-angular": "^0.13.2",
    ...
    "@fortawesome/fontawesome-free": "^5.8.0",
    ...
  }
}

This setup is being used in an Angular 7 project.

Answer №1

To obtain the font awesome pack, you will need to visit the font awesome website and download it. This package contains css, js files, as well as woff, svg, eot, and other necessary files.

When implementing in your HTML (both DEV and PROD environments), instead of using the CDN URL

<link rel="stylesheet" href="https://use.fontawesome.com/releases/v5.8.0/css/all.css">
, it is recommended to use relative paths to your fonts directory, which ideally should be located in the assets folder.

For example:

@font-face {
      font-family: Ionicons;
      src: url(../assets/fonts/ioniconsAI.eot?v=2.0.1);
      src: url(../assets/fonts/ioniconsAI.eot?v=2.0.1#iefix) format("embedded-opentype"), url(../assets/fonts/ioniconsAI.ttf?v=2.0.1) format("truetype"), url(../assets/fonts/ioniconsAI.woff?v=2.0.1) format("woff"), url(../assets/fonts/ioniconsAI.svg?v=2.0.1#Ionicons) format("svg");
      font-weight: 400;
      font-style: normal
    }

I hope this information proves helpful for you.

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

Adjusting button alignment when resizing the browser

Is there a method to relocate buttons using Bootstrap 5 in HTML or CSS when the browser is resized? For instance, if the button is centered on a full-screen browser, but I want it at the bottom when resized. Is this achievable? ...

The origin of the Angular img src becomes blurred when invoking a function

I want to dynamically change the image src by calling a function that returns the image path. However, when I attempt to do so using the code below, the image element displays as <img src(unknown)/> component.ts: getMedia(row) { this.sharedData ...

Errors are not displayed or validated when a FormControl is disabled in Angular 4

My FormControl is connected to an input element. <input matInput [formControl]="nameControl"> This setup looks like the following during initialization: this.nameControl = new FormControl({value: initValue, disabled: true}, [Validators.required, U ...

What is the best way to organize controls on my website?

My web page controls need to be organized in the specific layout below: Header Left Content - Main Content - Right Content Footer Is there a control available that can assist me with achieving this layout? I prefer not to use a table since it may not b ...

Using .htaccess with Angular is specifically designed to function within a subfolder of

After deploying my app on a Debian 11 Apache server within the folder var/www/html (specifically in var/www/html/foo), I encountered issues with routing and hard refreshing, resulting in a 404 error whenever I attempted to refresh a page. The Angular app c ...

The grid elements are not in perfect alignment

I'm having trouble aligning the <p> element to the left and the image to the right. The image is not aligning properly with the fourth column, so I need to figure out how to fix that. .content{ display: grid; grid-template-columns: 25% 25 ...

Connecting data from a .ts file in one webpage to the HTML content of another webpage

I am currently working on implementing the binding concept in Angular. The code snippet below is from PageOne.ts: this.navCtrl.push("PageTwo",{ paramType: params, }) Here is a snippet from PageTwo.html: <span>{{paramType}}</span> ...

Create a fixed navbar while scrolling in Angular 5

I want to make a change to the menu position so that it becomes fixed when it reaches the top of the page. Here is my approach: import { Component, OnInit, Inject, HostListener } from '@angular/core'; import {Location} from '@angular/common ...

The header template may sometimes fail to load the CSS file

Being new to php, I suspect there is a simple solution that I have yet to discover. I've created a header template for all pages, but the css page changes based on the user's current page. How can I use php to determine how many levels up in a f ...

What is the process for incorporating a dropdown field and editable field within a container?

Looking to create a unique setup by incorporating dropdown fields and editable text fields within a designated box, similar to the image provided. Any tips on how to successfully implement this design? https://i.sstatic.net/6tGMp.jpg ...

Error! Unable to Inject ComponentFactoryResolver

Recently, I attempted to utilize ComponentFactoryResolver in order to generate dynamic Angular components. Below is the code snippet where I am injecting ComponentFactoryResolver. import { Component, ComponentFactoryResolver, OnInit, ViewChild } from "@an ...

How to troubleshoot the issue of "Error: (SystemJS) module is not defined" in Angular 2?

I am a beginner in the world of Angular2. It is known that in Angular2, there is a way to reference a file using a relative path by defining moduleId : module.id in the component meta data. However, I have tried doing it this way and keep encountering the ...

What is the process for sending JSON data in a file to a django rest api?

Currently, I am using Angular on the front-end and Django Rest on the back-end. I have encountered a scenario where I need to create a complex model. Despite considering other simpler solutions, I believe that using JSON to pass the files can streamline th ...

Issue with input width percentage not functioning as expected

Is there a special method to specify the width of an input field in CSS without it extending beyond the container? I want my input field to be 98% of the container's width, but when I set it to that, it goes off the screen. This is the HTML code I am ...

What is causing the inconsistency and instability in this jQuery sortable configuration?

I have created a page where users can interact with green blocks by dragging and re-ordering them from one sliding area to another. Sometimes, however, the dropping and sorting functionality is unreliable. The boxes may align incorrectly or the drop area m ...

When a user reverts UI changes to their original values in Angular reactive forms, does the pristine state reset?

I need the Submit button in my form to only be enabled when there is a change in the input. If the values in the form controls remain unchanged, the Submit button should be disabled. Initially, I attempted to utilize the FormGroup.pristine flag for toggl ...

Tips for eliminating the gap between Bootstrap 4 columns

Is there a way to eliminate the spacing between Bootstrap columns? I have three columns set up using Bootstrap but no matter what I do, I can't seem to get rid of the space between them. <!doctype html> <html lang="en> <head> ...

Exploring Angular 17's unique approach to structuring standalone components

Is something wrong with my code if I can only see the footer, header, and side-nav components on localhost? How can I fix this? app.component.html <div class="container-fluid"> <div class="row"> <div class=&q ...

Position the div to align with just one side of the table-cell

I am struggling with making the height of my code dependent on only the left column, while still allowing the right column to be scrollable if it contains more content than the left column. Despite my best efforts, I can't seem to figure out how to a ...

Guide on updating a value in a Firestore document using Firebase

I am working on updating a specific portion of a document in my Firebase collections structure, specifically the phonebook(map) section. https://i.sstatic.net/UmHot.png When attempting to modify the document, I encountered an error saying Invalid documen ...