Created
March 21, 2014 08:19
-
-
Save d4rkie/9681880 to your computer and use it in GitHub Desktop.
compass config. emulates a 5th output style I'd call "optimize"
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Require any additional compass plugins here. | |
if Sass::VERSION =~ /3.1/ | |
raise "you should upgrade to Sass version 3.2" | |
end | |
# Set this to the root of your project when deployed: | |
http_path = "/" | |
css_dir = "/css" | |
sass_dir = "/scss" | |
images_dir = "/img" | |
javascripts_dir = "/js" | |
# You can select your preferred output style here (can be overridden via the command line): | |
# output_style = :expanded # or | |
# output_style = :nested # or | |
# output_style = :compact # or | |
output_style = :compressed | |
# To enable relative paths to assets via compass helper functions. Uncomment: | |
relative_assets = true | |
# To disable debugging comments that display the original location of your selectors. Uncomment: | |
line_comments = false | |
# when using SCSS: | |
sass_options = { | |
:syntax => :scss, | |
:unix_newlines => true | |
} | |
# auto decompress the css after save | |
on_stylesheet_saved do |filename| | |
if File.exists?(filename) | |
unminify(filename) | |
end | |
end | |
def unminify(filename) | |
raise "file not found #{filename}" unless File.exists? filename | |
text = [] | |
File.open(filename, 'r:UTF-8') do |f| | |
f.each_line do |line| | |
line.strip! | |
code = line | |
.split("\t").join(" ") | |
.gsub(/\s*{\s*/i, " {\n ") | |
.gsub(/;\s*/i, ";\n ") | |
.gsub(/,\s*/i, ", ") | |
.gsub(/[ ]*}\s*/i, "}\n") | |
.gsub(/\}/i, "\n}") | |
.gsub(/\n (?<r>[^:]+):\s*/i, "\n " + '\k<r>: ') | |
.gsub(/ @/, '@') | |
.gsub(/\*\/((?<r>.*))/, "*/\n" + '\k<r>') | |
text.push(code) | |
end | |
end | |
File.open(filename, 'w:UTF-8') do |f| | |
f.write(text.join("\n").strip + "\n") | |
end | |
end | |
# If you prefer the indented syntax, you might want to regenerate this | |
# project again passing --syntax sass, or you can uncomment this: | |
# preferred_syntax = :sass | |
# and then run: | |
# sass-convert -R --from scss --to sass sass scss && rm -rf sass && mv scss sass |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment