mattmanske / slimmer

Middleman Starter Template
MIT License
30 stars 4 forks source link

how to install fonts with bower #3

Open afknapping opened 10 years ago

afknapping commented 10 years ago

i am trying to add font-awesome to my project. how would you recommend to enable the webfonts? i cannot reference them directly since they are in the bower directory, which is not served publicly.

mattmanske commented 10 years ago

If it's just Font Awesome, I would avoid the Bower package altogether and use their CDN instead [http://fontawesome.io/get-started/#bootstrapcdn].

Let me know if that's somehow not possible/ideal in your situation and perhaps we can figure something else out.

afknapping commented 10 years ago

I'd like to keep it usable when being offline.

I could probably add a folder for "unmanaged assets" within source, clone the font-awesome repo in there and import the font-files from there. Not ideal, but that way I can still pull changes easily when updating bower dependencies.

I guess this problem is with every bower package which brings other assets than css and js (thinking of media like images/sprites, videos, etc). So it would be cool to have a solution within the template for that.

Shooting in the dark here, but an idea is that you specifiy files that should be served and an relative path where they will be found. Example:

project.yaml:

title: Slimmer Project
static_assets:
  font_awesome:
    source_path: "bower/font-awesome/fonts/"
    deploy_path: "/fonts/font-awesome/"

project.sass:

@import "font-awesome/scss/font-awesome" // specifies $fa-font-path in a sub import
$fa-font-path: "/fonts/font-awesome/"

Not sure about leading and trailing slashes. Also not sure if this really makes sense. Maybe there is a sprockets-convention for cases like this?

mattmanske commented 10 years ago

Thats a solid point ~ there's inevitably going to be non-css/js assets that will need to be brought into the mix.

I think you might be on the right track, but I don't believe YAML files get brought in early enough in the compiling cycle to be able to reach outside of the source directory via sprockets.

I think the proper solution would be similar, but might have to originate in the Middleman config file. I'll play around later tonight and see what if I can do. If you find a working solution yourself, feel free to submit a pull-request as well.

afknapping commented 10 years ago

for now i went with cloning the whole fa repo into my assets folder. read a lot of comments on recent pull requests of sprockets, rails, sprockets-sass, sprockets-helpers, asf. looks to me like there is no "final" solution yet.

also found how to explicitly precompile files in sprockets/rails:

config.assets.precompile = [ 'file.ext' ]

but do not get how to transfer to middleman config.

dinko commented 9 years ago

Did you ever find an offline solution? I'm running into the same problem and wonder whether to clone it like you mentioned via a grunt task…or…to have a better solution :)