SASS
  • Introduction
  • 安裝SASS
  • compass sass
  • why learn SASS
  • @mixin指令介紹
  • Sass的表达式和控制命令
  • Special symbols of SASS
  • Keyframes
  • 強制置中
Powered by GitBook
On this page

Was this helpful?

安裝SASS

PreviousIntroductionNextcompass sass

Last updated 5 years ago

Was this helpful?

我們要學sass要用sass當然是要先安裝他囉,跟著下面步驟即可順利使用及運行sass囉。

安裝Ruby環境

由於Sass是採用Ruby程式語言所寫的,因此系統需先安裝Ruby環境才能使用,因此得先到Ruby官網下載並安裝。

安裝SASS

開啟命令提示字元,輸入gem install sass指令,再按下Enter鍵。

安裝Compass

安裝好Sass後,接著再輸入gem install compass指令。

安裝Autoprefixer

Autoprefixer是一個自動幫CSS加上前輟詞的工具,輸入gem install autoprefixer-rails

之後在sass專案的設定檔最底下可以加上以下程式碼

Encoding.default_external = 'utf-8'
sourcemap = true
cache = false
asset_cache_buster {|*args| nil }


require 'autoprefixer-rails'
on_stylesheet_saved do |file|
    css = File.read(file)
    map = file + '.map'
    if File.exists? map
        result = AutoprefixerRails.process(css,
        from: file,
        to:   file,
        map:  { prev: File.read(map), inline: false })
    File.open(file, 'w') { |io| io << result.css }
    File.open(map,  'w') { |io| io << result.map }
    else
        File.open(file, 'w') { |io| io << AutoprefixerRails.process(css) }
    end
end

這樣就完成囉,可以去建立SASS專案囉~。

下載點