Reputation: 55
I am trying to deploy client and server code to heroku from a single git repo. when I run "npm run build" I get this :
But there is no folder being created so I can't deploy the app.
Here are my package.json scripts
"scripts": {
"serve": "vue-cli-service serve",
"build": "vue-cli-service build",
"lint": "vue-cli-service lint"
},
And here is my code to let our Express server know to serve our project:
(process.env.NODE_ENV === "production") {
app.use(express.static(__dirname + "/public", "../../client/build"));
app.get("*", (req, res) =>
res.sendFile(
path.join(__dirname, "../../client/build", "/public/index.html")
)
);
}
Upvotes: 1
Views: 236
Reputation: 31
Install Heroku CLI
Create a static.json file:
{
"root": "dist",
"clean_urls": true,
"routes": {
"/**": "index.html"
}
}
Add static.json file to git
git add static.json
git commit -m "add static configuration"
Deploy to Heroku
heroku login
heroku create
heroku buildpacks:add heroku/nodejs
heroku buildpacks:add https://github.com/heroku/heroku-buildpack-static
git push heroku master
Upvotes: 1