admin管理员组

文章数量:1208155

I'm experimenting with Vercel and want to run a TypeScript ExpressJS service there. There are plenty of turorials and I have something running. However, I am not happy with the way it's configured:

{
    "version": 2,
    "outputDirectory": "dist",
    "builds": [
        {
            "src": "dist/index.js",
            "use": "@vercel/node",
            "config": { "includeFiles": ["dist/**"] }
        }
    ],   
    "routes": [
        {
            "src": "/(.*)",
            "dest": "dist/index.js"
        }
    ]
}

This requires me to checkin the compiled JavaScript to the project's repo, which feels wrong as it's all generated code. If I switch to Vercel building the JavaScript on deployment, which is ideally what I want:

{
    "version": 2,
    "outputDirectory": "dist",
    "buildCommand": "npm run build",
    "routes": [
        {
            "src": "/(.*)",
            "dest": "dist/index.js"
        }
    ]
}

then Vercel returns the JavaScript in the index.js file rather than executingstrong text it. I assumed there must be a way to add:

"use": "@vercel/node",

to the build configuration, but if there is I can't find it or work out.

Is there a way to achieve what I want or am I stuck with checking-in generated JavaScript?

本文标签: javascriptCan I build AND run a TypeScript ExpressJS service in VercelStack Overflow