-
-
Notifications
You must be signed in to change notification settings - Fork 205
/
next.config.js
47 lines (44 loc) · 1.49 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
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',
'images.unsplash.com',
'static.gotsby.org',
'static.ghost.org',
'gatsby.ghost.io',
'ghost.org',
'repository-images.githubusercontent.com',
'www.gravatar.com',
'github.githubassets.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
}