ActiveAdmin 资产预编译错误
时,它给我一个
Undefined mixin 'global-reset'.
当 ActiveAdmin 尝试运行
rake assets:precompile
ActiveAdmin 0.3.4 错误。 我的 Gemfile 中有 ActiveAdmin 和资产组,其中包含 sass、coffee-rails 和 uglifier。
ActiveAdmin is giving me an
Undefined mixin 'global-reset'.
error when it try to run
rake assets:precompile
ActiveAdmin is 0.3.4.
I have ActiveAdmin and an assets group in my Gemfile with sass, coffee-rails and uglifier.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
我刚刚偶然发现了这一点。我发现问题出在我的 Production.rb 文件中的 config.assets.precompile 指令中。我在那里有一个正则表达式,它匹配来自
activeadmin
gem 的一些资产,这些资产不应该与预编译匹配。将选项更改为以下内容对我有用:我遇到的有问题的代码块是这样的:
它匹配来自
activeadmin
gem 的资产并将它们声明为独立清单,当资产管道尝试编译它们时,产生了这个错误。有关
config.assets.precompile
指令如何在 Rails 中工作的更多详细信息,请查看此 Gist 。I've just stumbled on this. The problem I had turned out to be in the
config.assets.precompile
directive in myproduction.rb
file. I had a regular expression there, which was matching some assets from theactiveadmin
gem, that should not be matched for precompilation. Changing the option to the following worked for me:The problematic code block I had was this:
It was matching assets from the
activeadmin
gem and declaring them as standalone manifests and when the asset pipeline tried to complie them, this error was produced.For more details on how the
config.assets.precompile
directive works in Rails, check out this Gist.正如 @dimitar 指出的那样,问题确实是,因为资产管道正在尝试编译部分文件,并且由于它们不是为自行编译而编写的,因此会出现依赖性问题。
根据您的应用程序,您可能需要包罗万象,特别是如果您的多个子文件夹中有许多 JS、CoffeScript 和 SCSS/SASS 文件。在这种情况下,您可能会遇到 Rails 抱怨,因为当删除全部内容时,某些内容未编译用于生产。
解决方案是捕获所有排除 SASS 部分的内容,_filename.css.[scss|sass] 这将解决它(对我有用!)。我还提供了其他 ActiveAdmin 建议中的一些其他提示,其中包括一些要编译的 ActiveAdmin 依赖项。这是我的代码:
The problem is indeed, as @dimitar points out, the line with the catch all because the asset pipeline is trying to compile partials and since they aren't written to be compiled on their own, dependency issues appear.
Depending on your app, you might need that catch all, specially if you have many JS, CoffeScript and SCSS/SASS files in several child folders. In that situation you might encounter that rails complains because something isn't compiled for production when the catch all is removed.
The solution is to have a catch all that excludes the SASS partials, _filename.css.[scss|sass] and that would solve it (worked for me!). I also included some other tips from other activeadmin suggestions including exactly some ActiveAdmin dependencies to be compiled. Here's my code:
在您的 CSS 文件中,您很可能具有:
但是,您正在尝试导入全局重置,因此您应该将其更改为:
希望这会有所帮助!
In your CSS file, you most likely have:
However, you are trying to import your global reset, so you should change that to:
Hope this helps!