ruby-on-rails - 如何在 Heroku 部署期间运行 "grunt build"(angular 和 ruby​​-on-rails 应用程序)

标签 ruby-on-rails git angularjs heroku gruntjs

我想在 Heroku 上部署一个 angular+rails 应用程序。该应用程序基于 Emmanual Oda's example code 构建,并使用 Grunt 编译其 Assets 。

与其在本地编译我的 Assets 然后将它们提交到 git,我更愿意在 Heroku 上编译它们。也就是说,我想在部署我的应用程序时自动在 Heroku 上运行 grunt build

有谁知道如何配置 Heroku 来执行此操作?

编辑

我知道 Node.js 应用程序可以进行服务器端 Assets 编译,例如使用 mbuchetics' fork of the heroku nodejs buildpack .但是,当我按照该站点上的说明推送到 Heroku 时,出现以下错误

-----> Fetching custom git buildpack... done

 !     Push rejected, no Cedar-supported app detected

编辑 2

目前,我正在使用在本地运行 grunt build 的 Rake 任务进行部署。

task :deploy do
  system("rm -rf ./public/*")       # empty the public directory
  system("cd ngapp; grunt build")

  # make a bogus manifest file to turn off asset compilation on heroku 
  #   see here: https://devcenter.heroku.com/articles/rails-asset-pipeline
  system("mkdir public/assets; touch public/assets/manifest-098f6bcd4621d373cade4e832627b4f6.json")  

  system("git add public/")
  system("git commit -m \"deploying...\"")
  system("git push heroku master")
end

最好是服务器端解决方案!

最佳答案

我相信这就是您想要的:http://www.angularonrails.com/deploy-angular-rails-single-page-application-heroku/

此解决方案使用多个构建包在生产环境中运行 grunt build。版本控制中没有构建工件。

关于ruby-on-rails - 如何在 Heroku 部署期间运行 "grunt build"(angular 和 ruby​​-on-rails 应用程序),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/20929033/

相关文章:

ruby-on-rails - DRY 概念、关系

ruby-on-rails - TypeError "can' t 使用omniauth-twitter gem 将 nil 转换为 String"

git - git中有分支历史吗?

angularjs - 如何在没有新模板的情况下在 Ionic 选项卡中呈现内容,而只需像在 Bootstrap 中切换选项卡

javascript - AngularJS + webpack 如何散列模板 html

ruby-on-rails - before_create 不起作用

ruby-on-rails - Rails before_destroy 回调数据库更改总是回滚

git - 如何防止 bitbake 为特定主机寻找镜像?

windows - 为什么 git 要我输入密码?

javascript - 问题 : ng-repeat with specific view should be displayed on click