Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/grails/5.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Ruby on rails 在Rails中预编译时,导入的文件中不共享SCSS变量_Ruby On Rails_Sass_Precompile - Fatal编程技术网

Ruby on rails 在Rails中预编译时,导入的文件中不共享SCSS变量

Ruby on rails 在Rails中预编译时,导入的文件中不共享SCSS变量,ruby-on-rails,sass,precompile,Ruby On Rails,Sass,Precompile,这是我的应用程序.scss文件: @import "variables"; @import "bootstrap-sprockets"; @import "bootstrap-overrides"; @import "bootstrap"; @import "fancybox/jquery.fancybox"; @import "fancybox/jquery.fancybox-thumbs"; @import "fancybox/jquery.fancybox-buttons"; @impor

这是我的
应用程序.scss
文件:

@import "variables";
@import "bootstrap-sprockets";
@import "bootstrap-overrides";
@import "bootstrap";
@import "fancybox/jquery.fancybox";
@import "fancybox/jquery.fancybox-thumbs";
@import "fancybox/jquery.fancybox-buttons";
@import "font-awesome";
@import "theme";
@import "magnific-popup";
@import "jquery.gritter";
@import "summernote";
@import "style";
@import "media";
我试着给“variables”文件命名
\u variables.scss
variables.scss
,但这两个文件都不起作用,因为当我预编译时,似乎所有东西都是按字母顺序预编译的。因此,只要
media.scss
开始预编译,我就会收到以下错误:

Sass::SyntaxError: Undefined variable: "$white".
/Users/Trevor/Work/SplitRock/app/assets/stylesheets/_media.scss:3
/Users/Trevor/.rvm/gems/ruby-2.2.2/gems/sass-3.4.13/lib/sass/script/tree/variable.rb:49:in `_perform'
/Users/Trevor/.rvm/gems/ruby-2.2.2/gems/sass-3.4.13/lib/sass/script/tree/node.rb:50:in `perform'
/Users/Trevor/.rvm/gems/ruby-2.2.2/gems/sass-3.4.13/lib/sass/tree/visitors/perform.rb:394:in `visit_prop'
/Users/Trevor/.rvm/gems/ruby-2.2.2/gems/sass-3.4.13/lib/sass/tree/visitors/base.rb:36:in `visit'
/Users/Trevor/.rvm/gems/ruby-2.2.2/gems/sass-3.4.13/lib/sass/tree/visitors/perform.rb:158:in `block in visit'
/Users/Trevor/.rvm/gems/ruby-2.2.2/gems/sass-3.4.13/lib/sass/stack.rb:79:in `block in with_base'
/Users/Trevor/.rvm/gems/ruby-2.2.2/gems/sass-3.4.13/lib/sass/stack.rb:115:in `with_frame'
/Users/Trevor/.rvm/gems/ruby-2.2.2/gems/sass-3.4.13/lib/sass/stack.rb:79:in `with_base'
/Users/Trevor/.rvm/gems/ruby-2.2.2/gems/sass-3.4.13/lib/sass/tree/visitors/perform.rb:158:in `visit'
/Users/Trevor/.rvm/gems/ruby-2.2.2/gems/sass-3.4.13/lib/sass/tree/visitors/perform.rb:430:in `block (2 levels) in visit_rule'
/Users/Trevor/.rvm/gems/ruby-2.2.2/gems/sass-3.4.13/lib/sass/tree/visitors/perform.rb:430:in `map'
/Users/Trevor/.rvm/gems/ruby-2.2.2/gems/sass-3.4.13/lib/sass/tree/visitors/perform.rb:430:in `block in visit_rule'
/Users/Trevor/.rvm/gems/ruby-2.2.2/gems/sass-3.4.13/lib/sass/tree/visitors/perform.rb:179:in `with_environment'
/Users/Trevor/.rvm/gems/ruby-2.2.2/gems/sass-3.4.13/lib/sass/tree/visitors/perform.rb:428:in `visit_rule'
/Users/Trevor/.rvm/gems/ruby-2.2.2/gems/sass-3.4.13/lib/sass/tree/visitors/base.rb:36:in `visit'
/Users/Trevor/.rvm/gems/ruby-2.2.2/gems/sass-3.4.13/lib/sass/tree/visitors/perform.rb:158:in `block in visit'
/Users/Trevor/.rvm/gems/ruby-2.2.2/gems/sass-3.4.13/lib/sass/stack.rb:79:in `block in with_base'
/Users/Trevor/.rvm/gems/ruby-2.2.2/gems/sass-3.4.13/lib/sass/stack.rb:115:in `with_frame'
/Users/Trevor/.rvm/gems/ruby-2.2.2/gems/sass-3.4.13/lib/sass/stack.rb:79:in `with_base'
/Users/Trevor/.rvm/gems/ruby-2.2.2/gems/sass-3.4.13/lib/sass/tree/visitors/perform.rb:158:in `visit'
/Users/Trevor/.rvm/gems/ruby-2.2.2/gems/sass-3.4.13/lib/sass/tree/visitors/base.rb:52:in `block in visit_children'
/Users/Trevor/.rvm/gems/ruby-2.2.2/gems/sass-3.4.13/lib/sass/tree/visitors/base.rb:52:in `map'
/Users/Trevor/.rvm/gems/ruby-2.2.2/gems/sass-3.4.13/lib/sass/tree/visitors/base.rb:52:in `visit_children'
/Users/Trevor/.rvm/gems/ruby-2.2.2/gems/sass-3.4.13/lib/sass/tree/visitors/perform.rb:167:in `block in visit_children'
/Users/Trevor/.rvm/gems/ruby-2.2.2/gems/sass-3.4.13/lib/sass/tree/visitors/perform.rb:179:in `with_environment'
/Users/Trevor/.rvm/gems/ruby-2.2.2/gems/sass-3.4.13/lib/sass/tree/visitors/perform.rb:166:in `visit_children'
/Users/Trevor/.rvm/gems/ruby-2.2.2/gems/sass-3.4.13/lib/sass/tree/visitors/base.rb:36:in `block in visit'
/Users/Trevor/.rvm/gems/ruby-2.2.2/gems/sass-3.4.13/lib/sass/tree/visitors/perform.rb:512:in `visit_media'
/Users/Trevor/.rvm/gems/ruby-2.2.2/gems/sass-3.4.13/lib/sass/tree/visitors/base.rb:36:in `visit'
/Users/Trevor/.rvm/gems/ruby-2.2.2/gems/sass-3.4.13/lib/sass/tree/visitors/perform.rb:158:in `block in visit'
/Users/Trevor/.rvm/gems/ruby-2.2.2/gems/sass-3.4.13/lib/sass/stack.rb:79:in `block in with_base'
/Users/Trevor/.rvm/gems/ruby-2.2.2/gems/sass-3.4.13/lib/sass/stack.rb:115:in `with_frame'
/Users/Trevor/.rvm/gems/ruby-2.2.2/gems/sass-3.4.13/lib/sass/stack.rb:79:in `with_base'
/Users/Trevor/.rvm/gems/ruby-2.2.2/gems/sass-3.4.13/lib/sass/tree/visitors/perform.rb:158:in `visit'
/Users/Trevor/.rvm/gems/ruby-2.2.2/gems/sass-3.4.13/lib/sass/tree/visitors/base.rb:52:in `block in visit_children'
/Users/Trevor/.rvm/gems/ruby-2.2.2/gems/sass-3.4.13/lib/sass/tree/visitors/base.rb:52:in `map'
/Users/Trevor/.rvm/gems/ruby-2.2.2/gems/sass-3.4.13/lib/sass/tree/visitors/base.rb:52:in `visit_children'
/Users/Trevor/.rvm/gems/ruby-2.2.2/gems/sass-3.4.13/lib/sass/tree/visitors/perform.rb:167:in `block in visit_children'
/Users/Trevor/.rvm/gems/ruby-2.2.2/gems/sass-3.4.13/lib/sass/tree/visitors/perform.rb:179:in `with_environment'
/Users/Trevor/.rvm/gems/ruby-2.2.2/gems/sass-3.4.13/lib/sass/tree/visitors/perform.rb:166:in `visit_children'
/Users/Trevor/.rvm/gems/ruby-2.2.2/gems/sass-3.4.13/lib/sass/tree/visitors/base.rb:36:in `block in visit'
/Users/Trevor/.rvm/gems/ruby-2.2.2/gems/sass-3.4.13/lib/sass/tree/visitors/perform.rb:186:in `visit_root'
/Users/Trevor/.rvm/gems/ruby-2.2.2/gems/sass-3.4.13/lib/sass/tree/visitors/base.rb:36:in `visit'
/Users/Trevor/.rvm/gems/ruby-2.2.2/gems/sass-3.4.13/lib/sass/tree/visitors/perform.rb:157:in `visit'
/Users/Trevor/.rvm/gems/ruby-2.2.2/gems/sass-3.4.13/lib/sass/tree/visitors/perform.rb:8:in `visit'
/Users/Trevor/.rvm/gems/ruby-2.2.2/gems/sass-3.4.13/lib/sass/tree/root_node.rb:36:in `css_tree'
/Users/Trevor/.rvm/gems/ruby-2.2.2/gems/sass-3.4.13/lib/sass/tree/root_node.rb:20:in `render'
/Users/Trevor/.rvm/gems/ruby-2.2.2/gems/sass-3.4.13/lib/sass/engine.rb:268:in `render'
/Users/Trevor/.rvm/gems/ruby-2.2.2/gems/sass-rails-5.0.3/lib/sass/rails/template.rb:47:in `evaluate'
/Users/Trevor/.rvm/gems/ruby-2.2.2/gems/tilt-1.4.1/lib/tilt/template.rb:103:in `render'
/Users/Trevor/.rvm/gems/ruby-2.2.2/gems/sprockets-3.0.2/lib/sprockets/legacy_tilt_processor.rb:25:in `call'
/Users/Trevor/.rvm/gems/ruby-2.2.2/gems/sprockets-3.0.2/lib/sprockets/processor_utils.rb:75:in `call_processor'
/Users/Trevor/.rvm/gems/ruby-2.2.2/gems/sprockets-3.0.2/lib/sprockets/processor_utils.rb:57:in `block in call_processors'
/Users/Trevor/.rvm/gems/ruby-2.2.2/gems/sprockets-3.0.2/lib/sprockets/processor_utils.rb:56:in `reverse_each'
/Users/Trevor/.rvm/gems/ruby-2.2.2/gems/sprockets-3.0.2/lib/sprockets/processor_utils.rb:56:in `call_processors'
/Users/Trevor/.rvm/gems/ruby-2.2.2/gems/sprockets-3.0.2/lib/sprockets/loader.rb:103:in `load_asset_by_uri'
/Users/Trevor/.rvm/gems/ruby-2.2.2/gems/sprockets-3.0.2/lib/sprockets/loader.rb:40:in `block in load'
/Users/Trevor/.rvm/gems/ruby-2.2.2/gems/sprockets-3.0.2/lib/sprockets/loader.rb:171:in `fetch_asset_from_dependency_cache'
/Users/Trevor/.rvm/gems/ruby-2.2.2/gems/sprockets-3.0.2/lib/sprockets/loader.rb:33:in `load'
/Users/Trevor/.rvm/gems/ruby-2.2.2/gems/sprockets-3.0.2/lib/sprockets/cached_environment.rb:20:in `block in initialize'
/Users/Trevor/.rvm/gems/ruby-2.2.2/gems/sprockets-3.0.2/lib/sprockets/cached_environment.rb:47:in `yield'
/Users/Trevor/.rvm/gems/ruby-2.2.2/gems/sprockets-3.0.2/lib/sprockets/cached_environment.rb:47:in `load'
/Users/Trevor/.rvm/gems/ruby-2.2.2/gems/sprockets-3.0.2/lib/sprockets/bundle.rb:23:in `block in call'
/Users/Trevor/.rvm/gems/ruby-2.2.2/gems/sprockets-3.0.2/lib/sprockets/utils.rb:183:in `dfs'
/Users/Trevor/.rvm/gems/ruby-2.2.2/gems/sprockets-3.0.2/lib/sprockets/bundle.rb:24:in `call'
/Users/Trevor/.rvm/gems/ruby-2.2.2/gems/sprockets-3.0.2/lib/sprockets/processor_utils.rb:75:in `call_processor'
/Users/Trevor/.rvm/gems/ruby-2.2.2/gems/sprockets-3.0.2/lib/sprockets/processor_utils.rb:57:in `block in call_processors'
/Users/Trevor/.rvm/gems/ruby-2.2.2/gems/sprockets-3.0.2/lib/sprockets/processor_utils.rb:56:in `reverse_each'
/Users/Trevor/.rvm/gems/ruby-2.2.2/gems/sprockets-3.0.2/lib/sprockets/processor_utils.rb:56:in `call_processors'
/Users/Trevor/.rvm/gems/ruby-2.2.2/gems/sprockets-3.0.2/lib/sprockets/loader.rb:103:in `load_asset_by_uri'
/Users/Trevor/.rvm/gems/ruby-2.2.2/gems/sprockets-3.0.2/lib/sprockets/loader.rb:40:in `block in load'
/Users/Trevor/.rvm/gems/ruby-2.2.2/gems/sprockets-3.0.2/lib/sprockets/loader.rb:171:in `fetch_asset_from_dependency_cache'
/Users/Trevor/.rvm/gems/ruby-2.2.2/gems/sprockets-3.0.2/lib/sprockets/loader.rb:33:in `load'
/Users/Trevor/.rvm/gems/ruby-2.2.2/gems/sprockets-3.0.2/lib/sprockets/cached_environment.rb:20:in `block in initialize'
/Users/Trevor/.rvm/gems/ruby-2.2.2/gems/sprockets-3.0.2/lib/sprockets/cached_environment.rb:47:in `yield'
/Users/Trevor/.rvm/gems/ruby-2.2.2/gems/sprockets-3.0.2/lib/sprockets/cached_environment.rb:47:in `load'
/Users/Trevor/.rvm/gems/ruby-2.2.2/gems/sprockets-3.0.2/lib/sprockets/base.rb:63:in `find_asset'
/Users/Trevor/.rvm/gems/ruby-2.2.2/gems/sprockets-3.0.2/lib/sprockets/base.rb:70:in `find_all_linked_assets'
/Users/Trevor/.rvm/gems/ruby-2.2.2/gems/sprockets-3.0.2/lib/sprockets/manifest.rb:138:in `block in find'
/Users/Trevor/.rvm/gems/ruby-2.2.2/gems/sprockets-3.0.2/lib/sprockets/legacy.rb:114:in `block (2 levels) in logical_paths'
/Users/Trevor/.rvm/gems/ruby-2.2.2/gems/sprockets-3.0.2/lib/sprockets/path_utils.rb:223:in `block in stat_tree'
/Users/Trevor/.rvm/gems/ruby-2.2.2/gems/sprockets-3.0.2/lib/sprockets/path_utils.rb:207:in `block in stat_directory'
/Users/Trevor/.rvm/gems/ruby-2.2.2/gems/sprockets-3.0.2/lib/sprockets/path_utils.rb:204:in `each'
/Users/Trevor/.rvm/gems/ruby-2.2.2/gems/sprockets-3.0.2/lib/sprockets/path_utils.rb:204:in `stat_directory'
/Users/Trevor/.rvm/gems/ruby-2.2.2/gems/sprockets-3.0.2/lib/sprockets/path_utils.rb:222:in `stat_tree'
/Users/Trevor/.rvm/gems/ruby-2.2.2/gems/sprockets-3.0.2/lib/sprockets/legacy.rb:105:in `each'
/Users/Trevor/.rvm/gems/ruby-2.2.2/gems/sprockets-3.0.2/lib/sprockets/legacy.rb:105:in `block in logical_paths'
/Users/Trevor/.rvm/gems/ruby-2.2.2/gems/sprockets-3.0.2/lib/sprockets/legacy.rb:104:in `each'
/Users/Trevor/.rvm/gems/ruby-2.2.2/gems/sprockets-3.0.2/lib/sprockets/legacy.rb:104:in `logical_paths'
/Users/Trevor/.rvm/gems/ruby-2.2.2/gems/sprockets-3.0.2/lib/sprockets/manifest.rb:136:in `find'
/Users/Trevor/.rvm/gems/ruby-2.2.2/gems/sprockets-3.0.2/lib/sprockets/manifest.rb:162:in `compile'
/Users/Trevor/.rvm/gems/ruby-2.2.2/gems/sprockets-rails-2.2.4/lib/sprockets/rails/task.rb:70:in `block (3 levels) in define'
/Users/Trevor/.rvm/gems/ruby-2.2.2/gems/sprockets-3.0.2/lib/rake/sprocketstask.rb:147:in `with_logger'
/Users/Trevor/.rvm/gems/ruby-2.2.2/gems/sprockets-rails-2.2.4/lib/sprockets/rails/task.rb:69:in `block (2 levels) in define'
Tasks: TOP => assets:precompile
(See full trace by running task with --trace)

事实证明,我基本上已经将所有文件添加到了预编译中,这打乱了预编译顺序。它甚至尝试在不需要的时候预编译引导sass gem。通过删除一组通配符解决了这个问题

下面是
assets.rb中的问题行:

Rails.application.config.assets.precompile+=%w(grister/**.js*.css*.png*.gif*.jpeg*.jpg)

我改为:

Rails.application.config.assets.precompile+=%w(grister/*fancybox/*welcome.js)

可能的重复: