Rails 4 asset pipeline losing vendor assets

荒凉一梦 提交于 2020-01-03 08:59:30

问题


I can't seem to figure out how to make sprockets find assets in vendor/assets. I've ben been pushing off the problem by adding all of my assets to app/assets, but it's becoming way too cluttered.

I have read the documentation, and tried adding all of the following lines to my application.rb file.

config.assets.paths << "#{Rails.root}/vendor/assets/*"
config.assets.paths << "#{Rails.root}/vendor/assets/fonts"
config.assets.paths << "#{Rails.root}/vendor/assets/stylesheets"
config.assets.precompile << Proc.new { |path|
  if path =~ /\.(eot|svg|ttf|woff)\z/
    true
  end

They work locally, but when I push them to the server, none of my vendor assets are there. I'm using capistrano for deployments, and I know that there were some issues with the upgrade. That could be the root of the problem, but I followed the documentation to get it deploying (almost) everything alright.


回答1:


The problem turned out to be me being stupid, and quick to jump the gun on other problems. I dove too far down the rabbit hole, and lost sight of what was happening. I did not include the otf filetype in the regex, and it wasn't being included.

Facepalm

EDIT:

To clarify: all I had to do was change

if path =~ /\.(eot|svg|ttf|woff)\z/

to

if path =~ /\.(eot|svg|ttf|woff|otf)\z/



回答2:


When you run rake assets:precompile are you manually setting the env to production?

The command should read:

RAILS_ENV=production rake assets:precompile



来源:https://stackoverflow.com/questions/19205936/rails-4-asset-pipeline-losing-vendor-assets

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!