Friday, 16 August 2013

Rake: Running advanced rules

Rake: Running advanced rules

I wrote a rule to compress one-by-one every HTML, CSS, and JS file from
"src" directory and store them in "build" directory.
rule %r{^build/.*\.(html|css|js)$} => [
proc { |targ|
targ.sub(%r{^build/}, 'src/')
}
] do |t|
puts t.source, t.name
system("gzip --best --no-name --verbose --stdout #{t.source} > #{t.name}")
end
However, I could figure out how to run this rule.
task :default => [%r{^build/.*\.(html|css|js)$}]

➤ rake
rake aborted!
Don't know how to build task '(?-mix:^build\/.*\.(html|css|js)$)'
Tasks: TOP => default
(See full trace by running task with --trace)

No comments:

Post a Comment