-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathnext.config.js
More file actions
109 lines (93 loc) · 2.71 KB
/
next.config.js
File metadata and controls
109 lines (93 loc) · 2.71 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
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
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
/** @type {import('next').NextConfig} */
const path = require('path');
const withPlugins = require('next-compose-plugins');
const withSvgr = require('next-plugin-svgr');
const withBundleAnalyzer = require('@next/bundle-analyzer');
const isDebugMode = process.env.NEXT_PUBLIC_DEBUG_MODE === 'true';
const isDevelop = process.env.NEXT_PUBLIC_APP_ENV === 'develop';
const isProduction = process.env.NEXT_PUBLIC_APP_ENV === 'production';
const isAnalze = process.env.NEXT_PUBLIC_ANALYZE === 'true';
const bundleAnalyzer = withBundleAnalyzer({
enabled: isAnalze,
});
console.log('------------------------------------------------------------');
console.log('----------- Environment Variables Information --------------');
console.log({
isDebugMode,
isDevelop,
isProduction,
isAnalze,
});
console.log('------------------------------------------------------------');
const nextConfig = {
swcMinify: true,
eslint: {
dirs: ['.'],
ignoreDuringBuilds: true,
},
typescript: {
ignoreBuildErrors: !!isDevelop,
},
poweredByHeader: false,
reactStrictMode: false,
productionBrowserSourceMaps: false,
generateEtags: true, // etags
images: {
remotePatterns: [
{
protocol: 'https',
hostname: '**',
},
],
},
sassOptions: {
includePaths: [path.join(__dirname, 'styles')],
prependData: `@import "@/styles/_font.scss";
@import "@/styles/_variables.scss";
@import "@/styles/_mixins.scss";
`,
},
async redirects() {
const redirects = [];
return redirects;
},
webpack: (config, { isServer, dev }) => {
// Note: we provide webpack above so you should not `require` it
// Perform customizations to webpack config
if (isServer) {
return config;
}
var isProduction = config.mode === 'production';
if (!isProduction) {
return config;
}
// shader support
config.module.rules.push({
test: /\.(glsl|vs|fs|vert|frag)$/,
exclude: /node_modules/,
use: ['raw-loader', 'glslify-loader'],
});
config.module.rules.push({
test: /\.svg$/,
use: ['@svgr/webpack', 'url-loader', 'svg-react-loader'],
});
if (!isServer) {
// We're in the browser build, so we can safely exclude the sharp module
config.externals.push('sharp');
}
config.optimization.splitChunks.maxAsyncRequests = 8;
config.optimization.splitChunks.maxInitialRequests = 8;
return config;
},
compiler: {
removeConsole:
isProduction && !isDebugMode
? {
exclude: ['error'],
}
: false,
emotion: false,
styledComponents: true,
},
};
module.exports = withPlugins([bundleAnalyzer, withSvgr], nextConfig);