Created
July 12, 2010 10:41
-
-
Save andreyvit/472349 to your computer and use it in GitHub Desktop.
This file contains hidden or 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 'rake/clean' | |
HAML = FileList['**/*.haml'] | |
LESS = FileList['**/*.less'] | |
COFFEE = FileList['**/*.coffee'] | |
HTML = HAML.ext('html') | |
CSS = LESS.ext('css') | |
JS = COFFEE.ext('js') | |
CLOBBER.include(HTML, CSS, JS) | |
rule '.html' => '.haml' do |t| | |
puts " HAML #{t.source}" | |
sh 'haml', t.source, t.name | |
end | |
rule '.css' => '.less' do |t| | |
puts " LESS #{t.source}" | |
sh 'lessc', t.source, t.name | |
end | |
rule '.js' => '.coffee' do |t| | |
puts "COFFEE #{t.source}" | |
sh 'coffee', '-c', t.source | |
end | |
desc "Build all HTML, CSS and JavaScript files" | |
task :default => (HTML + CSS + JS) | |
desc "Continuously watch for changes and rebuild files" | |
task :watch => [:default] do | |
require 'rubygems' | |
require 'fssm' | |
def rebuild | |
sh 'rake' | |
puts " OK" | |
rescue | |
nil | |
end | |
begin | |
FSSM.monitor(nil, ['**/*.coffee', '**/*.haml', '**/*.less']) do | |
update { rebuild } | |
delete { rebuild } | |
create { rebuild } | |
end | |
rescue FSSM::CallbackError => e | |
Process.exit | |
end | |
end |
@niksosf To avoid spamming everyone here, please contact me at [email protected] for further assistance. Also, if you are serious about web development, please stop using Windows, it will always be making things more difficult for you.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
@andreyvit
I added the line
require 'livereload'
to the Rakefile in the root dir
And I put livereload.rake in lib/tasks/.In livereload.rake, I changed both instances of :default to rebuild. Then when I run rake watch,
nothing happens.
So I thought, maybe it's monitoring and I should edit a shared.less file to see what happens. Indeed, after I edited and saved a sample file, something did happen:
C:/Users/Nik/.pik/rubies/Ruby-187-p299/bin/ruby.exe -I"lib;test" "C:/Users/Nik/.pik/rubies/Ruby-187-p299/lib/ruby/gems/1.8/gems/rake-0.8.7/lib/rake/ra
ke_test_loader.rb"
C:/Users/Nik/.pik/rubies/Ruby-187-p299/bin/ruby.exe -I"lib;test" "C:/Users/Nik/.pik/rubies/Ruby-187-p299/lib/ruby/gems/1.8/gems/rake-0.8.7/lib/rake/ra
ke_test_loader.rb"
C:/Users/Nik/.pik/rubies/Ruby-187-p299/bin/ruby.exe -I"lib;test" "C:/Users/Nik/.pik/rubies/Ruby-187-p299/lib/ruby/gems/1.8/gems/rake-0.8.7/lib/rake/ra
ke_test_loader.rb"
OK
rake
I also have another command prompt running the livereload server and it does not say that shared.css or shared.less is update.
Then I tried removing everything in that Rakefile in the root and inserting the livereload gist, leaving the two instances of :default as they are.
And then I run
rake watch
immediately, I see
LESS app/stylesheets/sessions/shared.less
lessc app/stylesheets/sessions/shared.less app/stylesheets/sessions/shared.css
And then I went to my texteditor to change something in the shared.less and saved it. This time, I got some pretty instant response:
rake
(in c:/r/bakery)
LESS app/stylesheets/sessions/shared.less
lessc app/stylesheets/sessions/shared.less app/stylesheets/sessions/shared.css
OK
with bakery dir being my rails app dir
And I see
in the livereload server prompt.
Unfortunately, though everything seems okay now, the webpage itself is not reloaded even when the livereload prompt detected a modification. And I made sure that the livereload is working for erb, css, html, js, and etc, while doing all the above.
I am running on Windows 7 64bit, Ruby 1.8.7.