ActiveAdmin资产预编译错误

问题描述:

ActiveAdmin是给我一个ActiveAdmin资产预编译错误

Undefined mixin 'global-reset'. 

错误,当它试图运行

rake assets:precompile 

ActiveAdmin是0.3.4。 我有ActiveAdmin和资产组在我的Gemfile与sass,咖啡栏和uglifier。

问题的确如@dimitar指出的那样,因为资产管道正试图编译partials,并且因为它们没有编写成独立编译,所以出现了依赖关系问题。

根据您的应用程序,您可能需要全部捕获,特别是如果您在多个子文件夹中有多个JS,CoffeScript和SCSS/SASS文件。在这种情况下,您可能会遇到rails抱怨,因为当catch全部被移除时,某些东西没有编译生产。

解决方案是捕获所有不包含SASS偏好的文件_filename.css。[scss | sass]并解决它(为我工作!)。我还包含了其他activeadmin建议的其他一些技巧,包括准确编译的一些ActiveAdmin依赖关系。这是我的代码:

# Include all JS files, also those in subdolfer or javascripts assets folder 
# includes for exmaple applicant.js. JS isn't the problem so the catch all works. 
config.assets.precompile += %w(*.js) 
# Replace %w(*.css *.js *.css.scss) with complex regexp avoiding SCSS partials compilation 
config.assets.precompile += [/^[^_]\w+\.(css|css.scss)$/] 
#Adding active_admin JS and CSS to the precompilation list 
config.assets.precompile += %w(active_admin.css active_admin.js active_admin/print.css) 
+0

奇怪,这似乎是编译js就好了,并忽略了css偏好罚款,但也似乎忽略非部分css – 2015-07-30 22:44:56

在你的CSS文件中,你最有可能:

@include 'global-reset'; 

但是,你要导入您的全局复位,所以你应该改变,要:

@import 'global-reset'; 

希望这有助于!

+0

这已经改变了。 – nvano 2011-12-22 18:06:18

我只是偶然发现了这一点。我遇到的问题是我的production.rb文件中的config.assets.precompile指令。我在那里有一个正则表达式,它匹配activeadmin宝石中的一些资源,这不应该与预编译相匹配。更改选项以下为我工作:

# Needed for the ActiveAdmin's manifest assets. 
config.assets.precompile += ['active_admin.css', 'active_admin.js'] 

有问题的代码块我是这样的:

# This one effectively turns every js/css file, which starts with 
# a letter or a number, into an includeable asset manifest (similar to 
# what application.js and application.css already are). 
# You may want to omit this line for your application. 
config.assets.precompile += [/^[a-z0-9]\w+\.(css|js)$/] 

它是从activeadmin宝石匹配的资产,并宣布他们作为独立的舱单和当资产管道试图编制它们,产生了这个错误。

关于how the config.assets.precompile directive works in Rails, check out this Gist的更多详情。