-
-
Notifications
You must be signed in to change notification settings - Fork 1.7k
fix(astro): Adjust Vite plugin config to upload server source maps #9541
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
Conversation
if (outDirPathname && rootDirName) { | ||
const relativePath = path.relative(rootDirName, outDirPathname); | ||
return `${relativePath}/**/*`; | ||
} | ||
|
||
// fallback to default output dir | ||
return 'dist/**/*'; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
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; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
would the following make sense here
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?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yeah we could do this but technically they should both always be available
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
assets
glob from the output directory stored in theconfig
object. 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.