ActiveAdmin资产预编译错误

nva*_*ano 2 ruby-on-rails sass activeadmin

ActiveAdmin给了我一个

Undefined mixin 'global-reset'.
Run Code Online (Sandbox Code Playgroud)

尝试运行时出错

rake assets:precompile
Run Code Online (Sandbox Code Playgroud)

ActiveAdmin是0.3.4.我的Gemfile中有ActiveAdmin和资产组,包括sass,coffee-rails和uglifier.

Dim*_*tar 14

我偶然发现了这一点.我原来的问题是config.assets.precompile在我的production.rb文件中的指令中.我在那里有一个正则表达式,它匹配activeadmingem中的一些资产,不应该与预编译匹配.将选项更改为以下内容对我有用:

# Needed for the ActiveAdmin's manifest assets.
config.assets.precompile += ['active_admin.css', 'active_admin.js']
Run Code Online (Sandbox Code Playgroud)

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

# 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)$/]
Run Code Online (Sandbox Code Playgroud)

它匹配来自activeadmingem的资产并将它们声明为独立的清单,当资产管道试图对它们进行编译时,就产生了这个错误.

有关指令如何config.assets.precompile在Rails中工作的更多详细信息,请查看此Gist.


Dav*_*aez 11

确实,正如@dimitar指出的那样,问题就在于捕获全部,因为资产管道正在尝试编译部分内容,并且因为它们不是自己编译的,所以会出现依赖性问题.

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

解决方案是有一个捕获所有排除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 )
Run Code Online (Sandbox Code Playgroud)