Skip to content
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

Fix external astro image usage #4147

Merged
merged 4 commits into from
Aug 5, 2022
Merged

Fix external astro image usage #4147

merged 4 commits into from
Aug 5, 2022

Conversation

crutchcorn
Copy link
Contributor

Changes

This PR is meant as somewhat of a companion piece to #4146 in order to enable running @astrojs/image inside of astro.config files.

Specifically, this PR works around the issue of import.meta.env not being defined in non-Vite environments like astro.config.

Testing

This was added to my local environment, and, alongside #4146 was the final blocker I needed to bypass in order to create a local rehype-astro-image plugin.

No tests were added, since I was not sure if this required tests or even how to properly add tests that rely on non-Vite environments. Happy to add them with a bit of guidance 😄

Docs

This is a bug fix, thusly no docs are needed

@changeset-bot
Copy link

changeset-bot bot commented Aug 4, 2022

🦋 Changeset detected

Latest commit: 2a980dd

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package
Name Type
@astrojs/image Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@github-actions github-actions bot added the pkg: integration Related to any renderer integration (scope) label Aug 4, 2022
@matthewp
Copy link
Contributor

matthewp commented Aug 4, 2022

Thanks! I'm assuming the Windows test failing is flakiness, will rerun.

@tony-sull
Copy link
Contributor

@crutchcorn thanks for opening this PR! How exactly will getImage be used outside of Vite?

Currently the integration is depending on a custom vite plugin to parse metadata from local image files, I don't think getImage would be able to handle local images without a larger change to move away from the Vite dependency there

@crutchcorn
Copy link
Contributor Author

@tony-sull So I actually wrote a Remark plugin that appears to work quite well for my needs outside of Vite:

https://github.com/unicorn-utterances/unicorn-utterances/blob/astro/astro.config.ts#L91-L158

Specifically, the only change needed was this line to work around non-Vite execution:

https://github.com/unicorn-utterances/unicorn-utterances/blob/astro/astro.config.ts#L114-L117

@natemoo-re natemoo-re merged commit c039ea9 into withastro:main Aug 5, 2022
@astrobot-houston astrobot-houston mentioned this pull request Aug 6, 2022
@crutchcorn crutchcorn deleted the fix-external-astro-image-usage branch April 9, 2023 07:42
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
pkg: integration Related to any renderer integration (scope)
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants