Skip to content

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

Merged
merged 3 commits into from
Nov 13, 2023

Conversation

Lms24
Copy link
Member

@Lms24 Lms24 commented Nov 13, 2023

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 the config 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.

Unverified

This commit is not signed, but one or more authors requires that any commit attributed to them is signed.
Comment on lines 93 to 99
if (outDirPathname && rootDirName) {
const relativePath = path.relative(rootDirName, outDirPathname);
return `${relativePath}/**/*`;
}

// fallback to default output dir
return 'dist/**/*';
Copy link
Member Author

@Lms24 Lms24 Nov 13, 2023

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.

@Lms24 Lms24 requested review from mydea and lforst November 13, 2023 10:57
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;
Copy link
Member

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

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?

Copy link
Member Author

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

@Lms24 Lms24 enabled auto-merge (squash) November 13, 2023 13:02
@Lms24 Lms24 merged commit d80e27b into develop Nov 13, 2023
@Lms24 Lms24 deleted the lms/fix-astro-sourcemaps-assets-glob branch November 13, 2023 13:15
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.

None yet

2 participants