简体   繁体   English

Heroku Node Buildpack for Rails 5 / Angular 2 app

[英]Heroku Node Buildpack for Rails 5 / Angular 2 app

I am trying to deploy a Rails 5 api with an Angular 2 front end, with the Angular code living an frontend folder inside of the main Rails project. 我正在尝试使用Angular 2前端部署Rails 5 api,Angular代码生成主Rails项目中的frontend文件夹。

I was able to deploy using this tutorial ( https://www.angularonrails.com/deploy-angular-2rails-5-app-heroku/ ), and specifically this custom Heroku buildpack ( https://github.com/jasonswett/heroku-buildpack-nodejs/stargazers ). 我能够使用本教程( https://www.angularonrails.com/deploy-angular-2rails-5-app-heroku/ )进行部署,特别是这个自定义的Heroku buildpack( https://github.com/jasonswett/) heroku-buildpack-nodejs / stargazers )。

While this buildpack is absolutely awesome for existing, I am a little uncomfortable depending on the custom implementation in the long run. 虽然这个buildpack对于现有的非常棒,但从长远来看,我有点不舒服,具体取决于自定义实现。 It also means I have to rename my frontend folder to client . 这也意味着我必须将我的frontend文件夹重命名为client

Is there a way to use the main Heroku Node buildpack, and somehow pass the path of my Angular frontend folder as an ENV variable? 有没有办法使用主Heroku Node buildpack,并以某种方式将我的Angular frontend文件夹的路径作为ENV变量传递? How would I go about doing this? 我该怎么做呢?

I've read through the Github conversations here ( https://github.com/heroku/heroku-buildpack-nodejs/pull/192 ) and here ( https://github.com/heroku/heroku-buildpack-nodejs/pull/203 ) but can't make heads or tails of it. 我在这里阅读了Github对话( https://github.com/heroku/heroku-buildpack-nodejs/pull/192 )和这里( https://github.com/heroku/heroku-buildpack-nodejs/pull) / 203 )但不能做它的正面或反面。

Please help! 请帮忙!

the trick is to place a package.json at root with the following: 诀窍是使用以下内容将package.json放在root用户:

{
    "scripts": {
        "postinstall": "cd frontend && npm install"
    }
}

substitute "frontend" with whatever folder the angular / node app is in. 用“角度/节点”应用程序所在的任何文件夹替换“前端”。

See github issues discussion here: https://github.com/heroku/heroku-buildpack-nodejs/issues/323#issuecomment-227520485 请参阅github问题讨论: https//github.com/heroku/heroku-buildpack-nodejs/issues/323#issuecomment-227520485

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM