forked from apache/arrow-site
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Rakefile
61 lines (54 loc) · 1.92 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
# -*- ruby -*-
#
# Licensed to the Apache Software Foundation (ASF) under one or more
# contributor license agreements. See the NOTICE file distributed with
# this work for additional information regarding copyright ownership.
# The ASF licenses this file to you under the Apache License, Version 2.0
# (the "License"); you may not use this file except in compliance with
# the License. You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
def production?
ENV["JEKYLL_ENV"] == "production"
end
webpacked_js = "javascript/main.js"
installed_package_lock_json = "node_modules/.package-lock.json"
file installed_package_lock_json => ["package.json", "package-lock.json"] do
if production?
sh("npm", "ci")
else
sh("npm", "install", "--no-save")
end
end
file webpacked_js => ["_webpack/main.js", installed_package_lock_json] do
rm_f(webpacked_js)
command_line = ["npx", "webpack"]
command_line << "--mode=production" if production?
sh(*command_line)
end
desc "Serve site locally"
task :serve => webpacked_js do
sh("jekyll",
"serve",
"--incremental",
"--livereload",
"--host", ENV["HOST"] || "127.0.0.1")
end
task :default => :serve
desc "Generate site"
task :generate => webpacked_js do
command_line = ["jekyll", "build"]
base_url = ENV["JEKYLL_BASE_URL"]
command_line << "--baseurl=#{base_url}" if base_url
extra_config = ENV["JEKYLL_EXTRA_CONFIG"]
command_line << "--config=_config.yml,#{extra_config}" if extra_config
destination = ENV["JEKYLL_DESTINATION"]
command_line << "--destination=#{destination}" if destination
sh(*command_line)
end