Deploying REST API to Vercel without commit dist files
Unanswered
Atlantic cod posted this in #help-forum
Atlantic codOP
I've read the following article: https://dev.to/tirthpatel/deploy-node-ts-express-typescript-on-vercel-284h and I've been able to deploy to Vercel without any issues, however I have to commit the build files for the deployment to work, which I think it's not a good practice. How can I fix this?
Basically what it does is build the API in each commit so then it's available transpiled under dist/index.js so it works after deploying, how can avoid commiting the dist folder?
If I remove the dist folder from the commited files and from
So it seems that it's not running the build command after deploying, but not sure why, any suggestions?
This is the vercel.json config in case it helps:
"scripts": {
"start": "nodemon src/index.ts",
"build": "rimraf dist && tsc",
"ts.check": "tsc --project tsconfig.json",
"add-build": "git add dist",
"test": "echo \"Error: no test specified\" && exit 1"
}, "pre-commit": [
"ts.check",
"build",
"add-build"
]Basically what it does is build the API in each commit so then it's available transpiled under dist/index.js so it works after deploying, how can avoid commiting the dist folder?
If I remove the dist folder from the commited files and from
add-build from the precommit, Vercel outputs the following error message:404: NOT_FOUND
Code: NOT_FOUND
ID: xxxxxxxxxxxxxxxSo it seems that it's not running the build command after deploying, but not sure why, any suggestions?
This is the vercel.json config in case it helps:
{
"version": 2,
"builds": [
{
"src": "dist/index.js",
"use": "@vercel/node",
"config": { "includeFiles": ["dist/**"] }
}
],
"routes": [
{
"src": "/(.*)",
"dest": "dist/index.js"
}
]
}