Conversation
BryonLewis
left a comment
There was a problem hiding this comment.
More like comments I want feedback on than changes.
- Questions about using the vite standard (
npm run dev,npm run previewinstead of oldervue-cli-servicecommands). - Configuration changes to make it easier to do local dev and testing of the client outside of docker without having to specify a .env file or env variables inline. This may be a selfish request for myself to make debugging things a bit easier.
| "dev": "vite", | ||
| "serve": "vite", | ||
| "serve:prod": "vite preview", | ||
| "build": "vite build", | ||
| "preview": "vite preview", |
There was a problem hiding this comment.
I think I'd rather keep dev and preview, seeing as the serve is typical for vue-cli-service, which is in maintenance mode and create-vue (vite based) is the recommendation that uses npm run dev/preview
If you feel strongly enough about it, I'm fine with changing it.
There was a problem hiding this comment.
Sure, create-vue calls it dev, so I'll keep that.
Full disclosure, I was somewhat trying to reconcile this configuration with that used by UVDAT, as both are Resonant projects with a Vue frontend, but I'll just suggest that UVDAT change instead.
I don't see a need for preview. Have you ever had a dev-prod disparity that you needed to debug? If so, I'm happy to add it back, it just seemed unnecessary for what we were doing.
There was a problem hiding this comment.
Yeah, that is exactly what I was using when debugging the maplibre/vite dependency issues. They were only showing up in the build version so I temporarily added in the /api proxy and configured the port for 8080 for the preview in vite.config.js while testing and determining the issue. I just didn't commit that change and only committed the vite/maplibre version changes.
| server: { | ||
| port: 8080, | ||
| strictPort: true, | ||
| }, |
There was a problem hiding this comment.
Adds back in the proxy for local running of npm run dev without having to configure environment variable either through a command VITE_APP_API_URL=http://localhost:8000 npm run dev. This again is mainly helpful when I'm testing incompatibilities between dependencies outside of docker like the maplibre/vite issue I experienced the other week. Also adds in the preview port to help with testing the build versions (maplibre/vite issue only showed up with the built version). I may be going overboard with enabling additional configurations so feel free to reject these one off things.
| server: { | |
| port: 8080, | |
| strictPort: true, | |
| }, | |
| server: { | |
| port: 8080, | |
| proxy: { | |
| "/api": { | |
| target: `http://localhost:8000`, | |
| xfwd: true, | |
| }, | |
| }, | |
| strictPort: true, | |
| }, | |
| preview: { | |
| port: 8080, | |
| proxy: { | |
| "/api": { | |
| target: `http://localhost:8000`, | |
| xfwd: true, | |
| }, | |
| }, | |
| strictPort: true, // If true, Vite will exit if the port is already in use | |
| }, |
There was a problem hiding this comment.
I disagree, I think VITE_APP_API_ROOT should just be mandatory, see my rationale in the other comment.
Additionally, in the interest of dev-prod parity, I think VITE_APP_API_ROOT is already fully sufficient to route requests to the API server, so we shouldn't need another dev-only proxy layer.
There was a problem hiding this comment.
I would probably like to keep the port:8080 then for vite:preview even if we remove the proxy, just because of local oauth setup configuration.
There was a problem hiding this comment.
| server: { | |
| port: 8080, | |
| strictPort: true, | |
| }, | |
| server: { | |
| port: 8080, | |
| strictPort: true, | |
| }, | |
| preview: { | |
| port: 8080, | |
| strictPort: true, | |
| } |
This also updates the TypeScript config from upstream
create-vue-app, so new type errors are detected.Note, for better consistency with other tools, the npm commands are now:
npm run servenpm run testFinally, this adds a build-time sanity check (since TypeScript alone can't actually guarantee that environment variables are set), to prevent regressions like #463. Now that
VITE_APP_API_ROOTis always defined the Vite config forserver.proxycan be removed (which only affects the development server).