Skip to content

Update config for Vite v8#471

Open
brianhelba wants to merge 5 commits intomainfrom
vite-8
Open

Update config for Vite v8#471
brianhelba wants to merge 5 commits intomainfrom
vite-8

Conversation

@brianhelba
Copy link
Copy Markdown
Member

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 serve
  • npm run test

Finally, 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_ROOT is always defined the Vite config for server.proxy can be removed (which only affects the development server).

Copy link
Copy Markdown
Collaborator

@BryonLewis BryonLewis left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

More like comments I want feedback on than changes.

  • Questions about using the vite standard (npm run dev, npm run preview instead of older vue-cli-service commands).
  • 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.

Comment on lines -7 to -9
"dev": "vite",
"serve": "vite",
"serve:prod": "vite preview",
"build": "vite build",
"preview": "vite preview",
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Copy link
Copy Markdown
Collaborator

@BryonLewis BryonLewis Apr 7, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Comment on lines +47 to +50
server: {
port: 8080,
strictPort: true,
},
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Suggested change
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
},

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Copy link
Copy Markdown
Collaborator

@BryonLewis BryonLewis Apr 7, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
server: {
port: 8080,
strictPort: true,
},
server: {
port: 8080,
strictPort: true,
},
preview: {
port: 8080,
strictPort: true,
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants