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

fix: serve and preview with base #8772

Closed
wants to merge 5 commits into from
Closed

fix: serve and preview with base #8772

wants to merge 5 commits into from

Conversation

JounQin
Copy link
Contributor

@JounQin JounQin commented Jun 24, 2022

Description

close #8770

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.

@netlify
Copy link

netlify bot commented Jun 24, 2022

Deploy Preview for vite-docs-main ready!

Name Link
🔨 Latest commit 5c2805a
🔍 Latest deploy log https://app.netlify.com/sites/vite-docs-main/deploys/62c1ccd301c1740008e9ca51
😎 Deploy Preview https://deploy-preview-8772--vite-docs-main.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site settings.

// redirect root visit to based url with search and hash
res.writeHead(302, {
Location: devBase + (parsed.search || '') + (parsed.hash || '')
Copy link
Contributor Author

Choose a reason for hiding this comment

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

parsed.search and parsed.hash will never be null/undefined.

.npmrc Outdated Show resolved Hide resolved
.npmrc Outdated Show resolved Hide resolved
package.json Outdated Show resolved Hide resolved
package.json Outdated Show resolved Hide resolved
@sapphi-red sapphi-red added the p2-nice-to-have Not breaking anything but nice to have (priority) label Jul 3, 2022
@JounQin JounQin changed the title fix: serve with base fix: serve and preview with base Jul 3, 2022
@benmccann
Copy link
Collaborator

This won't really work with SvelteKit. We have a trailingSlash option which indicates whether we expect URLs to have a trailing slash or not. This PR is currently assuming that there will always be a trailing slash, but for users who have chosen not to have one (which is the default in SvelteKit) it's not really correct.

Perhaps Vite should accept base with or without a trailing slash so that the user can decide which they would prefer or add a new trailingSlash option similar to SvelteKit's

@JounQin
Copy link
Contributor Author

JounQin commented Jul 19, 2022

@benmccann It didn’t work at all previously so would it break SvelteKit?

Of course I agree we should support base without slash.

@benmccann
Copy link
Collaborator

benmccann commented Jul 19, 2022

SvelteKit historically hasn't used the publicDir and base options, but does its own static asset serving. I put together a branch to use Vite's implementation. I came across this PR while looking at what Vite's implementation does and wanted to make sure to mention it so that we don't bake in too many assumptions. I filed an issue regarding support without a slash: #9236

@JounQin
Copy link
Contributor Author

JounQin commented Aug 3, 2022

@sapphi-red Any progress on this?

@sapphi-red
Copy link
Member

No, I've put this in the team board but not discussed yet.

@benmccann benmccann mentioned this pull request Nov 1, 2022
9 tasks
@patak-dev patak-dev closed this in 8f87282 Nov 12, 2022
tony19 pushed a commit to tony19/vite-docs-template that referenced this pull request Nov 12, 2022
Co-authored-by: Ben McCann <322311+benmccann@users.noreply.github.com>
Closes vitejs/vite#9236
Closes vitejs/vite#8770
Closes vitejs/vite#8772
docschina-bot pushed a commit to vitejs/docs-cn that referenced this pull request Nov 12, 2022
Co-authored-by: Ben McCann <322311+benmccann@users.noreply.github.com>
Closes vitejs/vite#9236
Closes vitejs/vite#8770
Closes vitejs/vite#8772
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
Archived in project
Development

Successfully merging this pull request may close these issues.

serve: with base: '/docs/', should /docs work as /docs/?
3 participants