-
-
Notifications
You must be signed in to change notification settings - Fork 1
/
next.config.js
53 lines (49 loc) · 1.64 KB
/
next.config.js
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
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
const withImageLoader = require('next-image-loader')
const { PHASE_EXPORT } = require('next/constants')
const withBundleAnalyzer = require('@next/bundle-analyzer')({
enabled: process.env.ANALYZE === 'true',
})
const defaultOptions = withBundleAnalyzer({
//...(process.env.NETLIFY === 'true' && { target: 'serverless' }),
images: {
deviceSizes: [320, 500, 680, 1040, 2080, 2048, 3120],
domains: [
'localhost',
'www.brian.dev',
'www.amazon.com',
'm.media-amazon.com',
'github.com',
'opengraph.githubassets.com',
'images.unsplash.com',
'static.ghost.org',
'ghost.org',
'repository-images.githubusercontent.com',
'www.gravatar.com',
'github.githubassets.com',
'lh5.googleusercontent.com',
'lh4.googleusercontent.com',
...(process.env.IMAGE_DOMAINS || '').split(','),
],
},
reactStrictMode: true,
})
/**
* The customImageLoaderOptions object is returned only when `next export` is used,
* since `next export` requires a custom image loader(https://nextjs.org/docs/advanced-features/static-html-export)
* which you can customize in image-loader.config.js
*/
const customImageLoaderOptions = withBundleAnalyzer(
withImageLoader({
...(process.env.NETLIFY === 'true' && { target: 'serverless' }),
// https://nextjs.org/docs/api-reference/next/image#loader
images: {
loader: 'custom',
},
reactStrictMode: true,
experimental: { esmExternals: true },
})
)
module.exports = (phase, { _defaultConfig }) => {
const isExport = process.env.IS_EXPORT || phase === PHASE_EXPORT
return isExport ? customImageLoaderOptions : defaultOptions
}