【问题标题】:Set sass options in Rails 4.1.4在 Rails 4.1.4 中设置 sass 选项
【发布时间】:2014-08-10 23:23:41
【问题描述】:

我正在尝试更改 Rails 应用程序中 sass 的行为,但没有任何效果。这是我到目前为止所做的总结。

我已经添加了

  config.sass.style = :compressed

在 config/application.rb 然后重新启动服务器但没有效果。之后我决定尝试使用 config/environments/development.rb 但相同。

所以我的问题是如何更改 sass 选项?

【问题讨论】:

    标签: ruby-on-rails sass


    【解决方案1】:

    尝试在config/initializersconfig/initializers/sass_options.rb 中创建一个文件,然后在文件中添加以下内容:

    require 'sass/plugin'    
    Sass::Plugin.options[:style] = :compressed
    

    重启服务器并重新尝试

    编辑:

    你在使用sass-rails gem 吗?如果您在开发模式下运行,它看起来像是硬编码为“扩展”https://github.com/rails/sass-rails/blob/master/README.md

    【讨论】:

    • 已尝试但出现错误。 /Users/trooper/Projects/rails/blog/config/initializers/sass_options.rb:1:in `': 未初始化的常量 Sass::Plugin (NameError)
    • 您在 Gemfile 中有 'sass' gem 对吗?顺便说一句,我已经编辑了答案,包括 'require'
    • 是的,我在 gemfile 中有 sass。添加 require 方法后,我没有错误,但 css 的输出没有按照选项行中的指定进行压缩。
    • 如果你在开发模式下运行,看起来 sass 总是'扩展'
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2012-07-17
    • 2012-11-09
    • 2016-04-30
    • 2014-08-27
    • 2023-03-03
    • 1970-01-01
    相关资源
    最近更新 更多