Created
August 30, 2013 22:20
-
-
Save TerasawaShuhei/6394861 to your computer and use it in GitHub Desktop.
Pygements を利用してると Jekyll Serve --watch のファイル生成が遅い問題を解決してくれる。
参考 → http://blog.eiel.info/blog/2013/08/30/jekyll-watch-very-slow/
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 'bundler/setup' | |
require 'thread' | |
require 'launchy' | |
require 'directory_watcher' | |
require 'jekyll' | |
desc 'preview' | |
task preview: [:watch] do | |
Thread.new do | |
sleep 2 | |
Launchy.open 'http://localhost:4000/' | |
end | |
sh 'bundle exec jekyll serve' | |
end | |
task :watch do | |
options = Jekyll.configuration({}) | |
source = options['source'] | |
destination = options['destination'] | |
dw = DirectoryWatcher.new(source, :glob => Jekyll::Command.globs(source, destination), :pre_load => true) | |
dw.interval = 1 | |
dw.add_observer do |*args| | |
t = Time.now.strftime("%Y-%m-%d %H:%M:%S") | |
print Jekyll.logger.formatted_topic("Regenerating:") + "#{args.size} files at #{t} " | |
sh 'bundle exec jekyll build' | |
puts "...done." | |
end | |
dw.start | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment