guard / guard-compass

Guard::Compass automatically rebuilds scss|sass files when a modification occurs taking in account your compass configuration.
https://rubygems.org/gems/guard-compass
MIT License
58 stars 11 forks source link

Watch multiple directories and output to multiple directories #12

Closed zeorin closed 11 years ago

zeorin commented 12 years ago

Hi,

I'd like to use guard to watch more than one directory and output to more than one directory, respectively.

You see, where I work we use one mvc framework installation base to serve more than one site (specifically a mobile and desktop version), and I'm often working on both at the same time. Each site has their own css directory, compass.rb file and setup in Gaurdfile. I'd like each site's sass files to be compiled into css in it's own css directory, whilst only having to run one guard (as the Guardfile lives in the project root).

Below is my current Guardfile:

guard 'livereload', :host => '127.0.0.1', :port => '35729' do
    watch(%r{.+\.(html|js|php|css|gif|jpeg|jpg|png)$})
end

guard 'compass', :project_path => 'www/specialeditions_html/', :configuration_file => 'www/specialeditions_html/compass.rb' do
    watch(%r{.+\.(sass|scss)$})
    watch(%r{images/.+\.(jpg|gif|png)$})
end
guard 'compass', :project_path => 'facebook/special_edition_html/', :configuration_file => 'facebook/special_edition_html/compass.rb' do
    watch(%r{.+\.(sass|scss)$})
    watch(%r{images/.+\.(jpg|gif|png)$})
end

But when I edit and save a .scss file in www/specialeditions_html/, the output in the terminal is:

unchanged facebook/special_edition_html/styles/main.scss
unchanged facebook/special_edition_html/styles/main.scss

It's like compass has started twice, but is watching the same directory (the second one in the Guardfile). Note that no changes have been compiled (confirmed in browser).

www/specialeditions_html/compass.rb:

environment = :development

css_dir = "styles"
http_path = "/specialeditions_html"
sass_dir = "styles"

output_style = :nested

relative_assets = true

sprite_engine = :chunky_png

www/special_edition_html/compass.rb:

environment = :development

css_dir = "styles"
http_path = "/special_edition_html"
sass_dir = "styles"

output_style = :nested

relative_assets = true

sprite_engine = :chunky_png

Is there a config I'm missing, or is this just not possible whilst running one instance of guard?

oliamb commented 11 years ago

I had never tested with two files and given the code, I'm pretty sure the config will be overriden on the second call. Feel free to improve.