css - Font Awesome with Rails -


i trying font awesome working rails app following: http://fontawesome.io/get-started/

i not wish use cdn want use other fonts have no cdn want understand how non cdn fonts working: https://github.com/540co/govicons

i have downloaded , extracted font awesome into:

/app/assets/fonts/font-awesome-4.7.0 

i don't know if using css or sass? in stylesheets folder have files both css , sass extensions. have application.css file , empty application.scss file. other files have scss extension.

if follow scss instructions step 2 is:

open project's font-awesome/less/variables.less or font-awesome/scss/_variables.scss , edit @fa-font-path or $fa-font-path variable point font directory.

this file located in:

/app/assets/fonts/font-awesome-4.7.0/scss/_variables.scss 

this variable reads:

$fa-font-path: "../fonts" !default;

what should updated to?

i move these vendor/assets instead of app/assets because (source)

vendor/assets assets owned outside entities, such code javascript plugins , css frameworks

mkdir -p vendor/assets mv font-awesome-4.7.0/ vendor/assets/ ls vendor/assets/font-awesome-4.7.0/ # css       fonts       less        scss 

and if you're using application.css, can just:

  1. edit app/assets/stylesheets/application.css
  2. add: *= require css/font-awesome in list of requires
  3. restart server , load page

and should working fine

if want use in scss:

  1. add app/assets/stylesheets/font_awesome.scss contents:

    $fa-font-path: "fonts"; @import "scss/font-awesome"; 
  2. add @import "font_awesome"; application.scss

the purpose of doing way don't have custom changes files in vendor/assets. downloaded site , can updated @ time without worrying whether you're going remember $fa-font-path changed custom path because done in files, not theirs.

note: you'd want use 1 of helpers (like asset-path) paths in assets, doesn't seem being used folder placeholder files given later. so, without wanting hunt through font-awesome , replace $fa-font-path asset-path, can this, current folder (in address bar, #{host}/assets/application-#{cache-buster}.css current folder /assets , /assets/fonts want (read: works me going through example).

govicons, looks you'd follow exact same steps above , should work out fine.


Comments

Popular posts from this blog

node.js - Node js - Trying to send POST request, but it is not loading javascript content -

javascript - Replicate keyboard event with html button -

javascript - Web audio api 5.1 surround example not working in firefox -