-
Notifications
You must be signed in to change notification settings - Fork 0
/
Rakefile
70 lines (61 loc) · 1.43 KB
/
Rakefile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
# Including only the changed build task
require 'rake'
require 'jekyll'
require 'nokogiri'
require 'open-uri'
require 'json'
require 'optparse'
require 'rake'
require 'etc'
require 'yaml'
require 'fileutils'
require 'nokogiri'
require 'json'
require 'listen'
require 'pp'
is_travis = ENV['TRAVIS'] == 'true'
is_prod = ENV['JEKYLL_ENV'] == 'production'
DEST_DIR = '_site'
$config = Jekyll.configuration({
:source => './',
:destination => DEST_DIR,
:timezone => 'America/Chicago',
:safe => false,
})
$config[:assets] ||= {}
$config[:assets][:plugins] ||= {}
$config[:assets][:plugins][:img] ||= {}
$config[:assets][:plugins][:img][:optim] = is_prod
if is_travis
pp $config
end
multitask default: [
] do
site = Jekyll::Site.new($config)
Jekyll::Commands::Build.build site, $config
cp './.travis.yml', './_site/.travis.yml'
end
multitask serve: [
'default',
] do
site = Jekyll::Site.new($config)
Jekyll::Commands::Serve.process $config
end
multitask watch: [
'default',
] do
site = Jekyll::Site.new($config)
listener = Listen.to('.', latency: 1.0) do |modified, added, removed|
begin
Jekyll::Commands::Build.build site, $config
rescue
end
end
listener.ignore(/\.\#.*/)
listener.ignore(/#{DEST_DIR}#{File::SEPARATOR}.*/)
$config['exclude'].each do |prefix|
listener.ignore(/#{prefix}#{File::SEPARATOR}.*/)
end
listener.start # not blocking
Jekyll::Commands::Serve.process $config
end