CSS is looking different on heroku

前端 未结 5 1852
一整个雨季
一整个雨季 2020-12-29 09:27

As you should see in the images below, the css on my local host site is spaced much better at the top than it is on heroku.

Has anyone had this type of problem bef

5条回答
  •  一个人的身影
    2020-12-29 09:54

    The problem is related to the handling of the asset pipeline on Heroku. There are several ways on how this can be handled, see http://devcenter.heroku.com/articles/rails31_heroku_cedar

    I fixed the issue in my application by pre-compiling the assets locally on my machine and then pushing them to Heroku.

    Pre-compile the assets:

    RAILS_ENV=production bundle exec rake assets:precompile
    

    Add/commit the changes to git repository:

    git add public/assets
    git commit -m "vendor compiled assets"
    

    To be safe I tested the whole thing on a local branch on my machine first which I pushed to Heroku using the following command (Heroku normally ignores all branches except the master branch, thus the trick):

    git push -f heroku heroku-assetpipeline:master
    

提交回复
热议问题