加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 百科 > 正文

ruby-on-rails – 使用Compass in rails可以为开发和生产设置不

发布时间:2020-12-17 04:29:40 所属栏目:百科 来源:网络整理
导读:假设我想为开发设置嵌套样式并为生产压缩. Compass配置文件中只有一个选项: output_style = :compact # or :nested,:expanded,:compressed 解决方法 它看起来很简单: output_style = RAILS_ENV == "production" ? :compressed : :nested 为了检查它,我在不
假设我想为开发设置嵌套样式并为生产压缩. Compass配置文件中只有一个选项:
output_style = :compact # or :nested,:expanded,:compressed

解决方法

它看起来很简单:
output_style = RAILS_ENV == "production" ? :compressed : :nested

为了检查它,我在不同的环境中运行这个rake任务(我必须在运行此任务之前更改sass源):

namespace :sass do
  desc 'Updates stylesheets if necessary from their Sass templates.'
  task :update => :environment do
    Sass::Plugin.update_stylesheets
  end
end

您可以将此任务放在lib / tasks / sass.rake中.

另外,我在Capistrano deploy.rb中运行此任务,以在部署期间自动更新生产中的样式表:

after 'deploy:restart','sass:update'

namespace :sass do
  desc 'Updates the stylesheets generated by Sass'
  task :update,:roles => :app do
    invoke_command "cd #{current_release}; rake sass:update RAILS_ENV=production"
  end
end

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读