-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathnext.config.js
More file actions
64 lines (61 loc) · 1.77 KB
/
next.config.js
File metadata and controls
64 lines (61 loc) · 1.77 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
const dotenv = require('dotenv');
const path = require('path');
const { existsSync } = require('fs');
const withBundleAnalyzer = require('@next/bundle-analyzer')({
enabled: process.env.ANALYZE === 'true',
});
module.exports = withBundleAnalyzer({
// Move env loading to the top level, outside the config
...loadEnv(),
i18n: {
locales: ['en', 'ru', 'hy'],
defaultLocale: 'en',
},
assetPrefix: process.env.NODE_ENV === 'development' ? '' : '/keepsimple_next',
async rewrites() {
return [
{ source: '/assets/:path*', destination: '/keepsimple_/assets/:path*' },
{ source: '/fonts/:path*', destination: '/keepsimple_/fonts/:path*' },
{ source: '/audio/:path*', destination: '/keepsimple_/audio/:path*' },
{ source: '/static/:path*', destination: '/keepsimple_/static/:path*' },
{ source: '/robots.txt', destination: '/keepsimple_/robots.txt' },
];
},
env: {
NEXTAUTH_URL: process.env.NEXTAUTH_URL,
},
compiler: {
removeConsole: process.env.NODE_ENV === 'prod',
},
eslint: {
ignoreDuringBuilds: true,
},
images: {
domains: [
'lh3.googleusercontent.com',
'cdn.discordapp.com',
'strapi.keepsimple.io',
'staging-strapi.keepsimple.io',
],
deviceSizes: [480, 640, 750, 828, 1080, 1200, 1920, 2048, 3840],
},
webpack(config) {
config.module.rules.push({
test: /\.svg$/i,
issuer: /\.[jt]sx?$/,
use: ['@svgr/webpack'],
});
return config;
},
productionBrowserSourceMaps: true,
});
function loadEnv() {
const envFile = `.env.${process.env.APP_ENV || 'local'}`;
const envPath = path.join(__dirname, envFile);
if (existsSync(envPath)) {
dotenv.config({ path: envPath });
} else {
console.error(`Env file not found: ${envPath}`);
}
return {};
}