How do you instruct Sprockets to include files from /vendors/assets/components on Heroku?

和自甴很熟 提交于 2019-12-13 14:45:52

问题


I want to manage clientside assets using Bower which installs resources such as angular into

/vendors/assets/components/angular/angular.js

I reference these assets in the application.css.scss file as follows:

/* ...
*= require bootstrap
*/

However while this works ok for development and the files are included ok, they're not getting picked up by sprockets for compilation in production on Heroku.

How can I instruct Sprockets to pick up and compile files from /vendor/assets/components/?


回答1:


You should be able to tell the pipeline to include extra directories like this:

config.assets.paths << Rails.root.join('vendor', 'assets', 'components')

You may also need to tell it to precompile specific files too, as only the main application.js & application.css are precompiled by default:

config.assets.precompile << %w( frontpage.css frontpage.js *.svg )

With Rails 4 on Heroku you need to add the 12factorapp gem

Finally, if you are using Heroku then for Rails 4 you'll need to add the following Gem

group :production do
  gem 'rails_12factor'
end

See this question for more information



来源:https://stackoverflow.com/questions/19546894/how-do-you-instruct-sprockets-to-include-files-from-vendors-assets-components-o

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