0

How to update Font Awesome to 5.x version?

Font Awesome

Note: Version 5 has been re-written and re-designed completely from scratch. Most of icons from version 4 is still same but some of icons will be not works. Please read this thread to know what is difference beetween two versions: https://fontawesome.com/how-to-use/on-the-web/setup/upgrading-from-version-4

Ready to update?

Install lbiraries

Make sure you have libraries module installed. Download latest verison of font-awesome 5 (https://github.com/FortAwesome/Font-Awesome) then extract to libraries folder at root of Drupal site. Then the folder structure will look like bellow:

libraries
  font-awesome
    css
      brands.css
      ...
      fontawesome-all.min.css
      ...
    webfonts
      fa-brands-400.eot
      ...

Write library_info_alter hook().

Open your .theme file (example benz_sub.theme if you are using Benz sub theme) and add function bellow:

/**
 * Implements hook_library_info_alter().
 */
function benz_sub_library_info_alter(&$libraries, $extension) {
  if ($extension == 'drupalexp' && \Drupal::moduleHandler()->moduleExists('libraries')) {
    if($path = libraries_get_path('font-awesome')){
      $libraries['font-awesome']['css']['base'] = [
        '/' . $path . '/css/fontawesome-all.min' => [],
      ];
    }
  }
}

Done. Don't forget to flush cache in Drupal.