Foundation Sites deploy to Heroku

限于喜欢 提交于 2019-12-11 05:41:46

问题


I've created a site using foundation sites. It's using the standard install using the Foundation CLI.

I've got the site running locally using foundation watch. When I push this to Heroku the build succeeds in the Heroku console but when I visit the site in a browser I only get an application error.

Heroku support has said I should be using $PORT in my startup script but I don't know where to configure this. This also seems strange as it's the first install.

Has anyone had similar problems?


回答1:


Here are some of the issue i find in your app.

Firstly heroku is not going to install any of your devDependencies, so make sure all dependencies required to build are in dependencies list.

Heroku searches for Procfile, which is used to launch app. If it doesnt find that, it will go with standard procedure.

In your case

It runs npm start. Which calls gulp to run build, server and watch( which is not necessary ).

Second heroku assign PORT number dynamically. But your server task binds a static port number 8000 from config.yml. So that may fail your app.

You dont need to use foundation watch in heroku as watch mode of files are not needed

You are required to run a server and server your files

My advice is to use expressJS server( because i have used it ) after your done building your app with gulp

In your start script(package.json), you can write something like

"scripts": {
    "start": "gulp && node server.js",
    "build": "gulp build --production"
  }

where server.js is expressjs server file. here's an example how you can write it.

Hope your problem will have less issues now.

Not to say about your github repo, but here are some points that might helpfull for you as well as for your clients/users or anybody.

  1. Why you have uploaded all node_modules and bower_components to github. When you have their respective json file, anyone can do npm install or bower install to download all required packages.
  2. Uploading node_modules and bower_components will be a headache for you as your push and clone size increases.


来源:https://stackoverflow.com/questions/37799254/foundation-sites-deploy-to-heroku

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!