Skip to content

Instantly share code, notes, and snippets.

@TerasawaShuhei
Created September 2, 2013 20:37
Show Gist options
  • Save TerasawaShuhei/6417073 to your computer and use it in GitHub Desktop.
Save TerasawaShuhei/6417073 to your computer and use it in GitHub Desktop.
Compass → config.rb
####################################
# COMPASS CONFIG #
# --------- #
# PUT config.rb ON PROJECT ROOT #
####################################
##================================##
# Require any additional compass plugins here.
##================================##
# compass-ceaser-easing
# https://github.com/jhardy/compass-ceaser-easing
require 'ceaser-easing'
##================================##
# additional_import_paths here.
##================================##
# additional_import_paths = ['/Users/shuuheyhey/Dropbox/framework/scss-bootstrap/','/Users/shuuheyhey/Dropbox/framework/font-size/']
##================================##
# STEP 1 #
##================================##
# CONFIGURE YOUR FOLDER NAMES #
##================================##
user_http_path = 'src/'
user_css_folder = 'src/css'
user_sass_folder = 'src/sass'
user_image_folder = 'src/img'
user_javascript_folder = 'src/js'
user_fonts_folder = 'src/fonts'
user_sasscache_folder = '/Users/shuuheyhey/.sass-cache'
##================================##
# STEP 2 #
##================================##
# :development or :production #
##================================##
environment = :development
########################################################################
########################################################################
# DO NOT MODIFY BELOW ~~ DO NOT MODIFY BELOW ~~ DO NOT MODIFY BELOW #
########################################################################
########################################################################
# General
relative_assets = true
project_path = File.dirname(__FILE__) + '/'
# Sass Paths
http_path = user_http_path
http_stylesheets_path = user_css_folder
http_images_path = user_image_folder
http_generated_images_path = user_image_folder
http_javascripts_path = user_javascript_folder
http_fonts_path = user_fonts_folder
cache_path = user_sasscache_folder
# Sass Directories
css_dir = user_css_folder
sass_dir = user_sass_folder
images_dir = user_image_folder
generated_images_dir = user_image_folder
javascripts_dir = user_javascript_folder
fonts_dir = user_fonts_folder
cache_dir = user_sasscache_folder
# Environment Rules
if environment == :development
p '##================================##'
p 'Development Environment'
p '##================================##'
p ' '
output_style = :expanded
line_comments = true
sass_options = {:sourcemap => true, :cache_location => cache_dir }
enable_sourcemaps = true
elsif environment == :production
p '##================================##'
p 'Production Environment'
p '##================================##'
p ' '
output_style = :compressed
line_comments = false
sass_options = { :cache_location => cache_dir }
enable_sourcemaps = false
on_stylesheet_saved do |filename|
if File.exists?(filename)
#Removing development sourcemap file
FileUtils.rm_rf(filename + '.map')
end
end
end
# COMPASS SPRITE CONFIG
# Make a copy of sprites with a name that has no uniqueness of the hash.
on_sprite_saved do |filename|
if File.exists?(filename)
FileUtils.cp filename, filename.gsub(%r{-s[a-z0-9]{10}\.png$}, '.png')
FileUtils.rm_rf(filename)
end
end
# Replace in stylesheets generated references to sprites
# by their counterparts without the hash uniqueness.
on_stylesheet_saved do |filename|
if File.exists?(filename)
css = File.read filename
File.open(filename, 'w+') do |f|
f << css.gsub(%r{(?<start>-s)(?<hash>[a-z0-9]{10})(?<file>\.png)}, '.png?v=\k<hash>')
end
end
end
@TerasawaShuhei
Copy link
Author

PATHは自分用に直してくださーい。

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment