Warning: file_get_contents(/data/phpspider/zhask/data//catemap/7/css/38.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
Css Rails/Compass/Sass编译速度非常慢_Css_Ruby On Rails_Compass Sass_Compass_Susy Compass - Fatal编程技术网

Css Rails/Compass/Sass编译速度非常慢

Css Rails/Compass/Sass编译速度非常慢,css,ruby-on-rails,compass-sass,compass,susy-compass,Css,Ruby On Rails,Compass Sass,Compass,Susy Compass,我知道这个问题已经被提过一千次了,我觉得我已经读过很多关于这个问题的帖子了,但我似乎仍然无法理解这个问题 我刚刚开始使用RubyonRails,并尝试在我的项目中使用Compass/Sass/Suzy。它们都可以工作(大部分),但我在compass编译器方面遇到了一些问题 首先,使用bundle exec compass watch(带和不带——poll)不会产生任何效果。(这是假设我理解了这个命令的要点,即它可以动态地重新编译,并且我不必刷新页面来查看我的更改,但我可能错了) 其次,当我在修改

我知道这个问题已经被提过一千次了,我觉得我已经读过很多关于这个问题的帖子了,但我似乎仍然无法理解这个问题

我刚刚开始使用RubyonRails,并尝试在我的项目中使用Compass/Sass/Suzy。它们都可以工作(大部分),但我在compass编译器方面遇到了一些问题

首先,使用
bundle exec compass watch
(带和不带
——poll
)不会产生任何效果。(这是假设我理解了这个命令的要点,即它可以动态地重新编译,并且我不必刷新页面来查看我的更改,但我可能错了)

其次,当我在修改.scss文件后刷新页面时,编译完成并重新加载页面需要30-35秒。这是无法忍受的。我读到最新的“指南针轨道”有一些问题,但大多数说这是几年前的文章。最新的指南针导轨是否工作完美,或者是否存在导致此问题的常见问题

因为我刚刚开始学习,我只有一个controller/view/scss文件,所以我很肯定我没有任何依赖循环问题

下面是我目前如何设置项目的。(我认为它设置正确,但可能有人会指出我做错了什么。)

  • 我创建了一个新的rails项目并生成了一个“欢迎”控制器
  • 修改了我的application.rb
  • application.rb

    require_relative 'boot'
    
    require 'rails/all'
    require 'susy'
    require 'compass'
    require 'breakpoint'
    require 'normalize-scss'
    # Require the gems listed in Gemfile, including any gems
    # you've limited to :test, :development, or :production.
    Bundler.require(*Rails.groups)
    
    module PersonalWeb
      class Application < Rails::Application
        # Settings in config/environments/* take precedence over those specified here.
        # Application configuration should go into files in config/initializers
        # -- all .rb files in that directory are automatically loaded.
      end
    end
    
  • 分别在my welcome.erb和welcome.scss中添加了一些HTML和sass
  • 作为进一步说明,我有一个问题,在每个编译罗盘上都抛出了一个不推荐的警告。我听从了似乎能阻止它的建议。我怀疑这其中有牵连,但为了防止我的无知妨碍解决问题,我想我还是提一下

    编辑

    我想我应该加入我的欢迎。SCS,以防我做了一些愚蠢的事情

    欢迎光临

    @import "normalize";
    @import "partials/variables";
    @import "partials/layout";
    @import "partials/mixins";
    @import "grids";
    
    header {
      height: 100px;
      background: $blue;
      color: $white;
      margin-bottom: 10px;
      padding: 10px;
    }
    
    .wrapper {
      background: $white;
      margin: 0 auto;
      max-width: 900px;
    }
    
    nav {
      text-align: center;
    
      ul, li {
        padding: 0;
      }
    
      li {
        background: $gray;
      }
    
      a {
        text-decoration: none;
        color: $white;
    
        &:hover {
          color: $yellow;
        }
      }
    }
    
    .first-row {
      height: 100px;
      margin-bottom: 10px;
      padding: 10px;
    }
    
    .first-row .first {
      background: $yellow;
      height: 100%;
    }
    
    .first-row .second {
      height: 100%;
    }
    
    .first-row .second div {
      background: $orange;
      height: 100%;
    }
    
    .pic-gallery {
      div {
        background: $violet;
        height: 100%;
        margin-bottom: 10px;
        padding: 10px;
      }
    }
    
    .content-bar {
      div {
        background: $green;
        height: 100%;
        margin-bottom: 10px;
        padding: 10px;
      }
    }
    
    footer {
      height: 100px;
      background: $blue;
      color: $white;
      margin-top: 10px;
      padding: 10px;
      clear: both;
    }
    
    header {
      @include full;
    
      .logo {
        @include span(wide 1.75);
        @include border-radius(0px);
      }
    
      h1 {
        @include span(last 2);
        @include breakpoint((max-width 50em)){
          @include span(last 2);
        }
      }
    }
    
    .wrapper {
      @include container;
    }
    
    编辑2
    我想我应该提到我在Windows 10上。

    当您在裸体项目或没有资产管道的框架上使用compass时,会使用
    compass watch
    命令。它监视文件系统的更改,并将SASS文件编译为CSS。它可以与一起使用,但这不是主要用途

    您不想将
    指南针手表
    与导轨一起使用。相反,Rails有一个内置的功能,可以更好地完成这项工作

    如果你仍然想使用指南针的其他功能,你应该使用宝石

    1.将gem添加到gem文件中 然后运行
    bundle
    安装gems

    2.设置您的
    应用程序.scss
    如果您有一个
    application.css
    文件,请将其重命名为
    application.scss
    。请注意,is不应命名为
    .css.scss
    。删除所有链轮指令,这些指令是如下注释:

    #= require 'foo'
    
    而是使用SASS
    @import
    指令:

    @import "compass"
    

    然后,要设置扩展,如susy。

    请尝试不导入整个compass

    相反,只导入所需的模块,即:

    @import "compass/typography/links/link-colors"
    
    • 取自

    您不需要在
    application.rb中要求gems,这是行
    Bundler.require(*Rails.groups)
    所做的。此外,在SASS中导入文件时,不包括扩展名。应该是
    @import“welcome”
    not
    welcome.scss
    。不给它命名.css.scss是一种惯例还是它会导致问题?很久以前就有了Sass rails。它也是超级愚蠢的,因为
    .scss
    扩展告诉我们它可以编译成CSS。好了,@max,我已经试过两次了。我做了一个新项目,将compass rails添加到gemfile中,运行了
    bundle
    。添加了gem
    susy
    。我又跑了。运行bundle exec compass install susy
    。我尝试添加
    config.compass.require“susy”
    ,但它显示未知变量
    config
    ,所以我将其取出。添加了一个控制器并运行了它,但scss更改仍然需要20-30秒才能编译。这无疑会大大加快速度
    #= require 'foo'
    
    @import "compass"
    
    @import "compass/typography/links/link-colors"