-
Notifications
You must be signed in to change notification settings - Fork 6.5k
Expand file tree
/
Copy pathnext.image.config.mjs
More file actions
33 lines (30 loc) · 1.33 KB
/
next.image.config.mjs
File metadata and controls
33 lines (30 loc) · 1.33 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
import { OPEN_NEXT_CLOUDFLARE } from './next.constants.cloudflare.mjs';
import { ENABLE_STATIC_EXPORT } from './next.constants.mjs';
const remotePatterns = [
'https://avatars.githubusercontent.com/**',
'https://bestpractices.coreinfrastructure.org/**',
'https://raw.githubusercontent.com/nodejs/**',
'https://user-images.githubusercontent.com/**',
'https://website-assets.oramasearch.com/**',
];
export const getImagesConfig = () => {
if (OPEN_NEXT_CLOUDFLARE) {
// If we're building for the Cloudflare deployment we want to use the custom cloudflare image loader
//
// Important: The custom loader ignores `remotePatterns` as those are configured as allowed source origins
// (https://developers.cloudflare.com/images/transform-images/sources/)
// in the Cloudflare dashboard itself instead (to the exact same values present in `remotePatterns` above).
//
return {
loader: 'custom',
loaderFile: './cloudflare/image-loader.ts',
};
}
return {
// We disable image optimisation during static export builds
unoptimized: ENABLE_STATIC_EXPORT,
// We add it to the remote pattern for the static images we use from multiple sources
// to be marked as safe sources (these come from Markdown files)
remotePatterns: remotePatterns.map(url => new URL(url)),
};
};