fix(astro): Adjust Vite plugin config to upload server source maps#9541
Merged
fix(astro): Adjust Vite plugin config to upload server source maps#9541
Conversation
Lms24
commented
Nov 13, 2023
Comment on lines
+93
to
+99
| if (outDirPathname && rootDirName) { | ||
| const relativePath = path.relative(rootDirName, outDirPathname); | ||
| return `${relativePath}/**/*`; | ||
| } | ||
|
|
||
| // fallback to default output dir | ||
| return 'dist/**/*'; |
Member
Author
There was a problem hiding this comment.
technically, these paths should always be set by Astro, even if users didn't set them explicitly in their config file. However, I think it makes sense to still fall back to a safe case in case anything went wrong before our integration came in.
lforst
reviewed
Nov 13, 2023
| function getSourcemapsAssetsGlob(config: AstroConfig): string { | ||
| // outDir is stored as a `file://` URL | ||
| const outDirPathname = config.outDir && config.outDir.pathname; | ||
| const rootDirName = config.root && config.root.pathname; |
Contributor
There was a problem hiding this comment.
would the following make sense here
Suggested change
| const rootDirName = config.root && config.root.pathname; | |
| const rootDirName = path.resolve(config.root && config.root.pathname); |
to fall back to cwd if the root is not defined?
Member
Author
There was a problem hiding this comment.
yeah we could do this but technically they should both always be available
lforst
approved these changes
Nov 13, 2023
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
For some reason our automatic assets detection in the Vite plugin doesn't work well in Astro builds. While client files were picked up and uploaded correctly, server-side source and map files were not uploaded.
This PR ensures we search for files to be uploaded in the entire output directory by building an
assetsglob from the output directory stored in theconfigobject. Once again Astro's integrations API comes in super handy here as this already gives us a custom output directory if users overwrote the default (/dist) one.