figmhq
Last Updated: June 16, 2017
·
32
· Kent Patrick

Sass + Compass compile two different files for development and production environment [Take 3]

Looking at the original 2 suggestions linked below helped me develop my own version that might help others
Sass + Compass compile two different files for development and production environment
Sass + Compass compile two different files for development and production environment [Take 2]
A merge of both the suggestions in the a both tips, gave me the following config.rb file

By simply using the usual compass compile or compass watch all files (nested, min, map) will be created with one script

require 'compass/import-once/activate'

preferred_syntax = :scss

http_path = "/"
css_dir = "public/skin/css"
sass_dir = "resources/scss"

if environment == :development
    line_comments = true
    output_style = :nested
    sass_options = {:debug_info => true}
else
    line_comments = false
    output_style = :compressed
    sass_options = {:debug_info => false}
    sourcemap = true

    require 'fileutils'
        on_stylesheet_saved do |file|
            if File.exists?(file)
            filename = File.basename(file, File.extname(file))
            File.rename(file, css_dir + "/" + filename + ".min" + File.extname(file))
        end
        on_stylesheet_saved do
          `compass compile -c config.rb -e development --force`
        end

    end
end
Say Thanks
Respond