你如何指示Sprockets在Heroku中包含来自/ vendors / assets / components的文件? [英] How do you instruct Sprockets to include files from /vendors/assets/components on Heroku?

查看:120
本文介绍了你如何指示Sprockets在Heroku中包含来自/ vendors / assets / components的文件?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想使用Bower来管理客户端资产,它将角度等资源安装到

/ vendors / assets / components / angular / angular中。 js



我在 application.css.scss 文件中引用这些资产,如下所示:

  / * ... 
* =需要引导程序
* /
code>

然而,虽然这对于开发很有用,并且文件包含在内,但它们并没有被链轮拾取以便在生产中进行编译

如何指示Sprockets从 / vendor / assets / components /

解决方案

你应该能够告诉管道包含这样的额外目录:

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

您也可以需要告诉它预编译特定的文件,因为只有主要的application.js& application.css是默认预编译的:

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



使用Heroku上的Rails 4,您需要添加12factorapp gem



最后,如果您使用的是Heroku,那么对于Rails 4,您需要添加以下Gem

  group:production do 
gem'rails_12factor'
end

请参阅这个问题的更多信息


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/?

解决方案

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

这篇关于你如何指示Sprockets在Heroku中包含来自/ vendors / assets / components的文件?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆