Fix assets not getting optimized when outDir
is outside the CWD
#8670
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.
Changes
astro:assets
and settingoutDir
to a folder outside of the project. For exampleoutDir: '../outside-the-project'
getOutDirWithinCwd
astro:assets
does not usegetOutDirWithinCwd
, so it ends up looking for the unoptimised assets at the wrong placeI wrote a slightly deeper explanation in #8668 (comment).
Testing
The minimal reproducible example in the issue above (https://github.com/MichailiK/astro-images-outdir-bug) was used to test this change. I don't think this would cause regressions. I believe this change just ensures that Astro is trying to obtain the unoptimised asset from the correct folder.
Docs
Since this is a bug, caused by an inconsistency between where
astro:assets
is looking for the assets & where they are actually located, I don't believe this needs docs changes.