Skip to content

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.

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 lforst and mydea 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
Contributor

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.

3 participants