资产管道和宝石

发布于 2025-01-05 03:53:43 字数 569 浏览 3 评论 0原文

假设我有一个引擎 gem A ,其中包含您的 application.css 和 application.js 这些文件通过 stylesheet_link_tagjavascript_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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

凑诗 2025-01-12 03:53:43

基本上,这个想法是始终仅链接 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 do stylesheet_link_tag('engine_a/application').

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文