-
-
Save noniq/1746744 to your computer and use it in GitHub Desktop.
# Usage: | |
# ruby concat.rb /path-to-compass-gem/frameworks/compass/stylesheets/_compass.scss > compass-all.scss | |
@seen = [] | |
def concat(file) | |
File.foreach(file) do |line| | |
if line =~ /^\s?@import "(.+?)";/ | |
import = $1 | |
unless @seen.include?(import) | |
@seen << import | |
puts "// IMPORTING #{import}" | |
import_filename = import.gsub(%r{([^/]+)$}, '_\1.scss') | |
import_path = File.exist?(File.dirname(file) + "/" + import_filename) ? File.dirname(file) : @basedir | |
concat("#{import_path}/" + import_filename) | |
end | |
else | |
puts line | |
end | |
end | |
end | |
@basedir = File.dirname(File.expand_path(ARGV[0])) | |
concat ARGV[0] |
Have you used this script in a Grunt/Yeoman setup? Any experience using this with grunt-contib-compass
?
I just tried it. Made me only 1 second faster, compass:server still takes about 5 seconds :-(
I just used this script for a Grunt/Yeoman project and reduced the build time to 1.1s ! Before it took 6+ seconds between save and live reload.
Thanks!
How can I use it with my Grunt project?
I have created concat.rb in C:\Ruby193\lib\ruby\gems\1.9.1\gems\compass-core-1.0.0.alpha.19\stylesheets and then tried to run 'ruby concat.rb' in the terminal but I receive the following: C:\Ruby193\lib\ruby\gems\1.9.1\gems\compass-core-1.0.0.alpha.19\stylesheets>ruby
concat.rb
concat.rb:20:in expand_path': can't convert nil into String (TypeError) from concat.rb:20:in
Am I missing something? (I'm new to Ruby)
If you're interested in a quick and dirty benchmark, I just compared the following grunt setups:
Before: grunt-contrib-compass / @include "compass/compass":
Completed in 3.966s …
Completed in 3.924s …
Completed in 4.013s …
Bypass lib but compile with compass: grunt-contrib-compass / @include "vendor/compass-all":
Completed in 2.899s …
Completed in 3.098s …
Completed in 2.899s …
Use SASS, bypass compass completely: grunt-contrib-sass / @include "vendor/compass-all":
Completed in 0.866s …
Completed in 0.816s …
Completed in 0.834s …
Thank you so much!
Damn, this has made things SO much quicker. Thank you so much. I've gone from waiting 4-5 seconds per compile to 0.5s or so.