Skip to content

Instantly share code, notes, and snippets.

@ro31337
Last active October 15, 2023 16:59
Show Gist options
  • Save ro31337/fde256c19074356e4f847a48f696658c to your computer and use it in GitHub Desktop.
Save ro31337/fde256c19074356e4f847a48f696658c to your computer and use it in GitHub Desktop.
Bulma font-awesome icons for Rails 6

Единственная запара возникла при подключении иконок к рельс6, решается так (app/javascript/packs/fa.scss)

@import "bulma/bulma";

$fa-font-path: '~@fortawesome/fontawesome-free/webfonts';
@import '~@fortawesome/fontawesome-free/scss/fontawesome';
@import '~@fortawesome/fontawesome-free/scss/solid'; // fas prefix
@import '~@fortawesome/fontawesome-free/scss/brands'; // fab prefix
// see https://fontawesome.com/how-to-use/with-the-api/setup/importing-icons for more prefixes

Установить через yarn:

  • yarn add @fortawesome/fontawesome-free
  • yarn add @fortawesome/free-brands-svg-icons
  • yarn add @fortawesome/free-solid-svg-icons
  • yarn add bulma

И в environment.js:

const { environment } = require('@rails/webpacker')
...
environment.loaders.get('sass').use.find(item => item.loader === 'sass-loader').options.includePaths = ['node_modules']

а в layout подрубается следующим образом:

<%= javascript_pack_tag 'fa', 'data-turbolinks-track': 'reload' %>

у вас должен быть пустой файлик fa.js в app/javascript/packs

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment