Update nanoc.rake
Keep compile step within one process
This commit is contained in:
parent
8f3a245f9a
commit
3d56ecb00e
2 changed files with 22 additions and 26 deletions
5
Rules
5
Rules
|
@ -27,10 +27,11 @@ Nanoc::RuleDSL::CompilerDSL.prepend(Nanoc::RuleDSL::RequireRules)
|
||||||
# Plugins
|
# Plugins
|
||||||
Nanoc::Webpack
|
Nanoc::Webpack
|
||||||
.default_argv
|
.default_argv
|
||||||
.concat ["--config", "webpack.#{buildenv}.js"]
|
.replace([*Nanoc::Webpack.default_argv, "--config", "webpack.#{buildenv}.js"].uniq)
|
||||||
|
|
||||||
Nanoc::Tidy
|
Nanoc::Tidy
|
||||||
.default_argv
|
.default_argv
|
||||||
.concat ["-upper"]
|
.replace([*Nanoc::Tidy.default_argv, "--config", "webpack.#{buildenv}.js"].uniq)
|
||||||
|
|
||||||
##
|
##
|
||||||
# See packages/typescript/postman
|
# See packages/typescript/postman
|
||||||
|
|
|
@ -1,42 +1,37 @@
|
||||||
# frozen_string_literal: true
|
require "bundler/setup"
|
||||||
|
require "nanoc"
|
||||||
|
cwd = File.realpath File.join(__dir__, "..", "..")
|
||||||
|
|
||||||
namespace :nanoc do
|
namespace :nanoc do
|
||||||
require "bundler/setup"
|
|
||||||
root = File.realpath File.join(__dir__, "..", "..")
|
|
||||||
|
|
||||||
desc "Clean the build/ directory"
|
desc "Clean the build/ directory"
|
||||||
task :clean do
|
task :clean do
|
||||||
Dir.chdir(root) do
|
Dir.chdir(cwd) do
|
||||||
sh "rm -rf node_modules/.cache/"
|
sh "rm -rf node_modules/.cache/"
|
||||||
|
sh "rm -rf build/"
|
||||||
sh "rm -rf tmp/"
|
sh "rm -rf tmp/"
|
||||||
sh "rm -rf build/al-quran/* build/*"
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
desc "Produce the build/ directory"
|
desc "Produce the build/ directory"
|
||||||
task :build, [:buildenv] do |t, args|
|
task :build, %i[buildenv] => %i[setenv] do |t, args|
|
||||||
Dir.chdir(root) do
|
Nanoc::CLI.run(["compile"])
|
||||||
buildenv = args.buildenv || ENV["buildenv"] || "development"
|
|
||||||
sass_path = File.join(root, "src", "css")
|
|
||||||
sh "rm -rf build/al-quran/css/"
|
|
||||||
Bundler.with_original_env {
|
|
||||||
sh "SASS_PATH=#{sass_path} buildenv=#{buildenv} bundle exec nanoc co"
|
|
||||||
}
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
|
|
||||||
desc "Produce the build/ directory on-demand"
|
desc "Produce the build/ directory on-demand"
|
||||||
task watch: ["nanoc:build"] do
|
task :watch, %i[buildenv] => %i[setenv nanoc:build] do |t, args|
|
||||||
Dir.chdir(root) do
|
|
||||||
require "listen"
|
require "listen"
|
||||||
srcdir = File.join(root, "src")
|
path = File.join(Dir.getwd, "src")
|
||||||
Listen.to(srcdir) do
|
Listen.to(path) do
|
||||||
Bundler.with_original_env { sh "rake nanoc:build" }
|
Nanoc::CLI.run(["compile"])
|
||||||
end.start
|
end.start
|
||||||
sleep
|
sleep
|
||||||
end
|
|
||||||
rescue Interrupt
|
rescue Interrupt
|
||||||
warn "SIGINT: exit"
|
warn "SIGINT: exit"
|
||||||
exit
|
exit
|
||||||
end
|
end
|
||||||
|
|
||||||
|
task :setenv, %i[buildenv] do |t, args|
|
||||||
|
ENV["SASS_PATH"] = File.join(cwd, "src", "css")
|
||||||
|
ENV["buildenv"] = args.buildenv || ENV["buildenv"] || "development"
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in a new issue