Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: support serving index.html in middleware mode #2871

Merged
merged 2 commits into from
May 23, 2021

Conversation

meowtec
Copy link
Contributor

@meowtec meowtec commented Apr 6, 2021

Description

I want to integrate vite (as a koa middleware) to my koa app for just development.

When middlewareMode enabled, vite will not handle the html request. I should serve them like this: Setting Up the Dev Server

I am not working on SSR, and I do not like to serve the html content by myself. Instead, the internal html middleware is enough for me.

It should be able to use indexHtmlMiddleware and spa fallback even when middlewareMode enabled.

Additional context


What is the purpose of this pull request?

  • Bug fix
  • New Feature
  • Documentation update
  • Other

Before submitting the PR, please make sure you do the following

  • Read the Contributing Guidelines.
  • Read the Pull Request Guidelines and follow the Commit Convention.
  • Check that there isn't already a PR that solves the problem the same way to avoid creating a duplicate.
  • Provide a description in this PR that addresses what the PR is solving, or reference the issue that it solves (e.g. fixes #123).
  • Ideally, include relevant tests that fail without this PR but pass with it.

@Shinigami92 Shinigami92 added the p2-nice-to-have Not breaking anything but nice to have (priority) label Apr 6, 2021
Copy link
Member

@patak-dev patak-dev left a comment

Choose a reason for hiding this comment

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

@meowtec we discussed this with Evan and this feature is approved. About the config API, we think that we should avoid the complexity of an object here.
Let's use proposal at #2871 (comment)

middlewareMode: 'html' | 'ssr' | true

Let's also update the documentation to use 'ssr' instead of true when explaining how to configure SSR.

Thanks for the work on this PR

@meowtec meowtec force-pushed the feat/serve-html-in-middleware-mode branch from d5c3334 to 03f9e09 Compare May 3, 2021 02:36
@meowtec meowtec force-pushed the feat/serve-html-in-middleware-mode branch from 03f9e09 to b811741 Compare May 19, 2021 02:18
@meowtec meowtec requested a review from patak-dev May 19, 2021 03:14
patak-dev
patak-dev previously approved these changes May 19, 2021
Copy link
Member

@patak-dev patak-dev left a comment

Choose a reason for hiding this comment

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

Looks like server.middlewareMode is not documented yet in https://vitejs.dev/config/#server-options. You may also want to include that in this PR or we can do it later. We may also need to think about how to add a test for 'html' mode to avoid future regressions.

@meowtec
Copy link
Contributor Author

meowtec commented May 20, 2021

Looks like server.middlewareMode is not documented yet in https://vitejs.dev/config/#server-options. You may also want to include that in this PR or we can do it later. We may also need to think about how to add a test for 'html' mode to avoid future regressions.

document added

@patak-dev patak-dev requested a review from antfu May 23, 2021 13:11
@antfu antfu merged commit b1598ce into vitejs:main May 23, 2021
ygj6 pushed a commit to ygj6/vite that referenced this pull request Jun 1, 2021
* feat: support for serving `index.html` in middleware mode

* docs: document `server.middlewareMode`
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
p2-nice-to-have Not breaking anything but nice to have (priority)
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants