Font Awesome working locally, but not on Heroku - heroku

So I Installed the font-awesome gem and everything looks good, using the latest version etc.
Also included in my application.css:
*= require font awesome
When I view from local it turns out fine and the glyph-icons show up. When I upload it to heroku, the icons do not show up. I originally had the block squares show up but managed to fix it as I had some messy code in my stylesheets.
What am I doing wrong or what am I missing?

Had the same issue and resolved it (in Rails 4) using info from the following two sources: Rails Asset Pipeline and Rails Asset Pipeline for Heroku
"With the asset pipeline, the preferred location for these assets is now the app/assets directory". Move the fonts folder for font-awesome into app/assets and the font awesome js and css files into vendor/assets or app/assets appropriate javascripts and stylesheets folders.
Now you need to compile the assets for production, run:
$ rake assets:precompile
$ RAILS_ENV=production bundle exec rake assets:precompile
$ git add public/assets
$ git commit -m "vendor compiled assets"
Then push to heroku
$ git push heroku master
Hopefully this helps someone else who stumbles upon this question.

Related

How to get jekyll to compile my sass when it changes?

I have a github pages site using the jekyll cayman theme, and I set up a sass stylesheet at assets/css/style.scss
Its contents begin:
---
# Front matter comment to ensure Jekyll properly reads file.
---
//DON'T DELETE THE ABOVE
#import "jekyll-theme-cayman";
and then I have the rest of my sass.
I then run bundle exec jekyll serve.
This used to work to start a server, and watch changes to the sass file and compile them to _site/assets/css/style.css.
I can see that it is picking up that there are changes in the sass file - the console logs: Regenerating: 1 file(s) changed at 2022-10-28 21:22:54 assets/css/style.scss - but nothing gets output to the style.css file. I've tried running bundle exec jekyll serve --watch.
That no longer works, and I'm not sure why. I noticed when I tried to run this for the first time in a while, it complained about nokogiri, so I ran bundle install - maybe that messed things up?
Try bundle exec jekyll clean && bundle exec jekyll serve or one command after the other. Clean removes files and cleans Sass and Jekyll caches. See https://jekyllrb.com/docs/usage/

unrequired files in github pages through jekyll

I'm fairly new to ruby and jekyll and I wanna start using jekyll to meu personal webpage. Among the files in my repo there is a'Gemfile' and 'Gemfile.lock' files.
The Gemfile is used to manage dependencis and Gemfile.lock is generated through
bundle install
Is any of them required to be in the repo, or does gh-pages overrides any definitions contained in those files?
Other contained folder is '.sass-cache'. From this question I get the impression that it's used for caching issues. Once again, is it required, or gh-pages generates those files itself?
You can version your Gemfile. This can be useful for a reinstall. gemfile.lock and .sass-cache are not necessary to push to Github. They are used locally.
If your Gemfile contains something other than:
source 'https://rubygems.org'
gem 'github-pages'
That certainly means that you use plugins that are not supported by Github (see supported plugins list here). You then need to generate your site locally and push the result to your Github.
I've described a workflow here and you can also have a look at Octopress rake file that can help for such a setup (need small hacks to be used on a basic Jekyll install).
From my interpretation of the docs, github simply uses their own github-pages gem to pull in dependencies and then runs jekyll serve on your repo.
One consequence of that is that your gemfile (and thus any gems not part of github-pages) is ignored. For example, I use jekyll-less to generate my CSS but since this is not part of github-pages, making CSS changes is a multi-step process for me:
Update .less files
Build
Copy compiled CSS out of _site
Commit .css changes
Push
Another consequence is that any run-time or build-time stuff you use is ignored by github, so your .sass-cache directory does not need to be added to the repo.

SASS in Octopress

My sass folder can not render screen.css when I rake generate, I don't know why, but it happens since I updated octopress, so, everytime I deploy my blog, I have to do the following steps:
go to _deploy and do git pull origin master
go back to root folder and do rake generate and rake deploy, after that,
go to my github repo, and manually edit stylesheets\screen.css to the previous version.
So, actually I have two questions:
How to add .stylesheets\screen.css in _deploy folder? (I rarely change the stylesheet, though..)
How to fix the "sass generator" so, it can work normally again?
Thank you..
Review your Rakefile and the code under task :generate do. It should be compiling the css file like system "compass compile -css dir #{source_dir}/stylesheets"

Files not being created on Heroku

I host my Jekyll-based blog (github code) on a Heroku cedar stack.
I build the jekyll files through my Rakefile:
namespace :assets do
desc 'Precompile assets'
task :precompile do
sh "bundle exec sass --update _scss:_css --style compressed"
sh "bundle exec jekyll"
end
end
This outputs the files into a _site directory, which is where Rack will serve the files from.
This has been working for over a year, and is working fine on the currently live version of my blog (released a fortnight ago):
$ heroku run ls _site
Running `ls _site` attached to terminal... up, run.9360
2012 404 apple-touch-icon.png back-end css front-end index.html politics public-domain.txt rss.xml
2013 410 assets config favicon.ico go.sh personal postsbytag robots.txt sitemap.xml
However, whenever I try to release anything now, or release the same version of the code to a new app, the _site directory doesn't seem to be created:
$ git push git push git#heroku.com:robinwinslow-dev.git
...
http://robinwinslow-dev.herokuapp.com deployed to Heroku
...
$ heroku run ls _site --app robinwinslow-dev
Running `ls _site` attached to terminal... up, run.2577
ls: cannot access _site: No such file or directory
And the site shows:
Internal Server Error
No such file or directory - _site/404/index.html
Does anyone know why this would have changed? Has anything changed in Heroku? Or have I suddenly done something stupid?
I don't know why this ever worked in the first place, because Heroku has a read-only file system. The solution would be to compile your site including all assets locally, check them into Git and then push the complete _site directory to Heroku.

Heroku doesnt precompile assets for rails4

The documentation here says that heroku with pre-compile assets during deployement in Rails4.
However ,
I dont see the precompile assets message.
Using thin (1.6.1)
Using twitter-bootstrap-rails (2.2.8)
Using uglifier (2.3.1)
Using will_paginate (3.0.4)
Your bundle is complete! It was installed into ./vendor/bundle
Bundle completed (1.37s)
Cleaning up the bundler cache.
-----> Writing config/database.yml to read from DATABASE_URL
Detected manifest file, assuming assets were compiled locally
-----> Discovering process types
Procfile declares types -> (none)
Default types for Ruby -> console, rake, web, worker
I am facing issues with bootstrap in my app, where the nav bar wont load properly + some other nuances and I think its the asset precompile issue.
I am using Rails4, Ruby2.0
I have assets enabled in application.rb
config.assets.enabled = true
Precompiling manually did not help
heroku run rake assets:precompile
Had this same problem. I had precompiled locally for some reason and then pushed to Heroku.
Saw Heroku give the line "Detected manifest file, assuming assets were compiled locally" which made me realize it wasn't precompiling all the things.
When I did a "git add ." and committed, I saw that it was adding a bunch of public files. Pushing that to Heroku got it to work. So I had to precompile and git add everytime, basically doing Heroku's work for it and making a mess in my public folder. It got the job done, but was a poor fix.
I looked for the "manifest" that heroku mentioned and eventually found a ".sprockets-manifest..." file in the public directory.
Deleted that and Heroku was once again my friend.
Found this question as part of my research so I thought I'd share what I found in case anyone else sees this, or has any elaborational thoughts.
Now I have to go and see if .sprockets-manifest was important to anything else ....
I struggled with the asset pipeline for a while. There seems to be a bit of confusion as to how the asset pipeline works among newer Rubyists. In my experience, this is my workflow to the asset pipeline for Heroku.
Make sure that assets work locally on localhost (required for Heroku)
Delete the public/assets folder in the Rails directory with rm -rf ./public/assets
Make a new assets directory with mkdir public/assets
Run the rake assets:precompile command
You should see a list of assets being precompiled in your command line
Once assets are precompiled, you should commit the changes via the following commands: git add -A then git commit -am "commit message goes here"
Finally, push to heroku via git push heroku master
NOTE: This bears repeating -- make sure your assets work normally on localhost before pushing to Heroku.
Deleting the public/assets folder helped. Also I ran heroku run rake assets:clean.
After that I could see:
----> Writing config/database.yml to read from DATABASE_URL
-----> Preparing app for Rails asset pipeline
Running: rake assets:precompile
The navbar loads fine now !
The message Detected manifest file, assuming assets were compiled locally is shown if there is .sprockets-manifest-*.json or manifest-*.json in public assets. So either removing individual file or whole public/assets works.
The source code for buildpack is here

Resources