Skip to content

Commit c17767a

Browse files
allow turning the local Netlify Image CDN on/off in dev (#14807)
Co-authored-by: Florian Lefebvre <[email protected]>
1 parent 2022e88 commit c17767a

File tree

2 files changed

+19
-7
lines changed

2 files changed

+19
-7
lines changed

.changeset/true-baboons-stand.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
'@astrojs/netlify': patch
3+
---
4+
5+
Fixes a case where disabling the local image CDN wasn't possible

packages/integrations/netlify/src/index.ts

Lines changed: 14 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -607,21 +607,28 @@ export default function netlifyIntegration(
607607
};
608608
}
609609

610-
const features = integrationConfig?.devFeatures;
610+
const features =
611+
typeof integrationConfig?.devFeatures === 'boolean'
612+
? {
613+
images: integrationConfig.devFeatures,
614+
environmentVariables: integrationConfig.devFeatures,
615+
}
616+
: {
617+
images: integrationConfig?.devFeatures?.images ?? true,
618+
environmentVariables: integrationConfig?.devFeatures?.environmentVariables ?? false,
619+
};
611620

612621
const vitePluginOptions: NetlifyPluginOptions = {
613622
images: {
614-
// We don't need to disable the feature, because if the user disables it
615-
// we'll disable the whole image service.
623+
// If features is an object, use the `images` property
624+
// Otherwise, use the boolean value of `features`, defaulting to true
625+
enabled: features.images,
616626
remoteURLPatterns: remoteImagesFromAstroConfig(config, logger),
617627
},
618628
environmentVariables: {
619629
// If features is an object, use the `environmentVariables` property
620630
// Otherwise, use the boolean value of `features`, defaulting to false
621-
enabled:
622-
typeof features === 'object'
623-
? (features.environmentVariables ?? false)
624-
: features === true,
631+
enabled: features.environmentVariables,
625632
},
626633
};
627634

0 commit comments

Comments
 (0)