-
Notifications
You must be signed in to change notification settings - Fork 4
/
next.config.js
68 lines (62 loc) · 2.35 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
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
const {
PHASE_DEVELOPMENT_SERVER,
PHASE_PRODUCTION_BUILD,
} = require("next/constants");
/** @type {import("next").NextConfig} */
module.exports = (phase) => {
// when `next build` or `npm run build` is used
const isProd =
phase === PHASE_PRODUCTION_BUILD && process.env.STAGING !== "1";
// when `next build` or `npm run build` is used
const isStaging =
phase === PHASE_PRODUCTION_BUILD && process.env.STAGING === "1";
// when started in development mode `next dev` or `npm run dev` regardless of the value of STAGING environmental variable
// or if flags `isProd / isStaging` turned false
const isDev = phase === PHASE_DEVELOPMENT_SERVER || (!isProd && !isStaging);
const env = {
nextImageExportOptimizer_imageFolderPath: "public/images",
nextImageExportOptimizer_exportFolderPath: "out",
nextImageExportOptimizer_quality: 90,
nextImageExportOptimizer_storePicturesInWEBP: true,
// If you do not want to use blurry placeholder images, then you can set
// nextImageExportOptimizer_generateAndUseBlurImages to false and pass
// `placeholder="empty"` to all <ExportedImage> components.
//
// If nextImageExportOptimizer_generateAndUseBlurImages is false and you
// forget to set `placeholder="empty"`, you'll see 404 errors for the missing
// placeholder images in the console.
nextImageExportOptimizer_generateAndUseBlurImages: true,
IS_PROD: () => !isDev,
NEXT_SEO_JLD_ANSWER: process.env.NEXT_SEO_JLD_ANSWER,
NEXT_SEO_JLD_QUESTION: process.env.NEXT_SEO_JLD_QUESTION,
NEXT_SEO_PREVIEW: process.env.NEXT_SEO_PREVIEW,
NEXT_SEO_TWITTER: process.env.NEXT_SEO_TWITTER,
NEXT_SEO_ABOUT: process.env.NEXT_SEO_ABOUT,
NEXT_SEO_TITLE: process.env.NEXT_SEO_TITLE,
NEXT_SEO_CANONICAL: process.env.NEXT_SEO_CANONICAL,
NEXT_IMG_PATH: process.env.NEXT_IMG_PATH,
NEXT_TELEMETRY_DISABLED: 1,
NEXT_PUBLIC_GA_ID: process.env.NEXT_PUBLIC_GA_ID,
};
// next.config.js object
return {
compiler: {
reactRemoveProperties: !isDev,
removeConsole: !isDev
},
trailingSlash: true,
productionBrowserSourceMaps: isDev,
swcMinify: isProd,
env: {
...env
},
reactStrictMode: true,
poweredByHeader: false,
images: {
minimumCacheTTL: 60,
formats: ["image/webp"],
loader: "custom",
deviceSizes: [320, 828, 1200, 1920],
}
};
};