mirror of
https://github.com/withastro/astro.git
synced 2024-12-16 21:46:22 -05:00
Fix external astro image usage (#4147)
* fix: enable @astrojs/image to be used inside of non-vite contexts * chore: add changeset Co-authored-by: Nate Moore <natemoo-re@users.noreply.github.com>
This commit is contained in:
parent
2675b8633c
commit
c039ea93a1
2 changed files with 7 additions and 1 deletions
5
.changeset/rude-falcons-smash.md
Normal file
5
.changeset/rude-falcons-smash.md
Normal file
|
@ -0,0 +1,5 @@
|
|||
---
|
||||
'@astrojs/image': patch
|
||||
---
|
||||
|
||||
Enable usage outside of vite contexts, such as the config file
|
|
@ -117,8 +117,9 @@ export async function getImage(
|
|||
|
||||
const attributes = await loader.getImageAttributes(resolved);
|
||||
|
||||
// `.env` must be optional to support running in environments outside of `vite` (such as `astro.config`)
|
||||
// @ts-ignore
|
||||
const isDev = import.meta.env.DEV;
|
||||
const isDev = import.meta.env?.DEV;
|
||||
const isLocalImage = !isRemoteImage(resolved.src);
|
||||
|
||||
const _loader = isDev && isLocalImage ? sharp : loader;
|
||||
|
|
Loading…
Reference in a new issue