如何使用 Guard 和 Rake 为部署到 Heroku 的 PhoneGap 应用预编译资产?

How do I precompile assets for a PhoneGap app deployed to Heroku using Guard and Rake?

我想将我的 (PhoneGap) 应用程序 www/ 部署到 Heroku。我更喜欢 HAML/SASS/CoffeeScript 所以我创建了一个 Guardfile 来自动生成 HTML/CSS/JS 并从 src/ 复制到 www/。我将 www/ 添加到 .gitignore。我想部署到 Heroku 并拥有 rake assets:precompile generate the 'slug'/www/ directory. I added a Rakefile according to the Guard example

require 'guard'

namespace :assets do
  desc "Precompile assets - build the whole app"
  task :precompile do
    Guard.run_all
  end
end

然而,当我尝试在本地 运行 时,run_all 失败了。

C:\Users\Chloe\workspace\TypeFunctions>bundle exec rake assets:precompile
rake aborted!
NoMethodError: undefined method `run_all' for Guard:Module
C:/Users/Chloe/workspace/TypeFunctions/Rakefile:6:in `block (2 levels) in <top (required)>'
Tasks: TOP => assets:precompile
(See full trace by running task with --trace)

我该如何解决这个问题? (或者有更好的方法吗?)

我必须添加

require 'guard/commander' 

(Wiki Source)

Guard.setup

尽管 the wiki 明确表示 # You can omit the call to Guard.setup, Guard.run_all will call Guard.setup under the hood if Guard has not been setuped yet

而且我似乎绝对需要 bundle exec...