资产管道和宝石
假设我有一个引擎 gem A ,其中包含您的 application.css 和 application.js 这些文件通过 stylesheet_link_tag
和 javascript_include_tag
加载。这很有效,每个人都很高兴。
然后是宝石B。该 gem 也有自己的 css/js,它希望 gem A 使用它。因此它将它注入到 gem A 的标头中,就像 stylesheet_link_tag('gem_b')
一样。在开发中工作正常,但在尝试部署时出现 AssetNotPrecompiled
异常。
那么我有什么样的解决方案呢?
我可以在主应用程序上使用 config.assets.precompile 。这就是我现在所做的,但这真的很糟糕。
有没有办法以某种方式注入 gem A application.css 清单?那将是最佳的。
谢谢。
Imagine that I have a engine gem A that has your application.css and application.js
Those files are loaded via stylesheet_link_tag
and javascript_include_tag
. This works and everybody is happy.
Then comes gem B. That gem also has it's own css/js that it wants gem A to use. So it injects it into the header of gem A like so stylesheet_link_tag('gem_b')
. Works fine in development but blows up when trying to deploy with AssetNotPrecompiled
exception.
So what kind of solution do I have?
I can use config.assets.precompile
on the main app. That's what I do now, but this really sucks.
Is there a way to inject into gem A application.css manifest somehow? That would be optimal.
Thanks.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
基本上,这个想法是始终仅链接 application.js/css 清单。因此,您不能安全地使用
stylesheet_link_tag('engine_a')
,但完全可以使用stylesheet_link_tag('engine_a/application')
。Basically the idea is to always to only link application.js/css manifests. So you can't safely use
stylesheet_link_tag('engine_a')
but you can totally dostylesheet_link_tag('engine_a/application')
.