vercelPreset changes build directory structure, breaking start script from remix docs
Closed this issue · 6 comments
I noticed that adding vercelPreset to my vite configuration breaks the remix-serve command which according to the remix docs should point to remix-serve ./build/server/index.js
but the index file is actually located at ./build/server/nodejs-[some random token-like string]/index.js . I thought there should be a way for remix or vite to know where it is. How are we supposed to author the start script for vercel with the presets? Is there a working example?
Why would you need to run a start script as opposed to running the remix vite:dev
dev server?
personally a few reasons:
- check output of prod build to see if it looks how I'd expect / debug something that only shows up in prod.
- making sure my understanding around how process.env.NODE_ENV works across development/production environments with vite. (e.g. its the only variable that I know of that is exposed across client/server)
- making sure useEffect works as expected (runs once in prod vs twice in dev because of StrictMode)
- making sure some CSP policy is applied correctly for prod.
- making sure other analytics scripts are being applied properly.
Fair enough. So you would need to adjust the file path in your "start" script to match the path which gets created with the plugin. Or you could disable the plugin for your local debugging / verification session.
I'll close this though since "changes build directory structure" is by design, and a result of the plugin's serverBundles
option usage.
Why would you need to run a start script as opposed to running the
remix vite:dev
dev server?
In order to test out the build locally because of some issues I'm only getting in production
Fair enough. So you would need to adjust the file path in your "start" script to match the path which gets created with the plugin. Or you could disable the plugin for your local debugging / verification session.
I'll close this though since "changes build directory structure" is by design, and a result of the plugin's
serverBundles
option usage.
Okay, thanks for helping me understand what's going on under the hood. I noticed the nodejs-ID folder is consistent. My repo is private right now and I was concerned I might be exposing some kind of secret by having the directory name in my scripts when it goes public.
Ya, the ID is generated based on the export const config
object's configuration (if any) in your routes, so it will be consistent with common route configurations.