问题
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.
- 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.
- 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