-
Notifications
You must be signed in to change notification settings - Fork 93
/
next.config.js
136 lines (128 loc) · 3.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
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
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
// @ts-check
const path = require('path')
const { withSentryConfig } = require('@sentry/nextjs')
const { version } = require('./package.json')
const { i18n } = require('./next-i18next.config')
/**
* NextJS Config Section
* @type {import('next').NextConfig}
*/
const moduleExports = {
i18n,
reactStrictMode: true,
sassOptions: {
includePaths: [path.join(__dirname, 'src/styles')],
},
typescript: {
tsconfigPath: 'tsconfig.build.json',
},
swcMinify: true,
webpack: (config) => {
config.experiments = { ...config.experiments, topLevelAwait: true }
return config
},
env: {
APP_ENV: process.env.APP_ENV,
APP_VERSION: version,
SENTRY_DSN: process.env.SENTRY_DSN,
DEPLOY_TAG: process.env.DEPLOY_TAG,
},
publicRuntimeConfig: {
APP_ENV: process.env.APP_ENV,
API_URL: process.env.API_URL,
APP_URL: process.env.APP_URL,
GTM_ID: process.env.GTM_ID ?? 'GTM-TWQBXM6',
PAYPAL_CLIENT_ID: process.env.PAYPAL_CLIENT_ID,
STRIPE_PUBLISHABLE_KEY: process.env.STRIPE_PUBLISHABLE_KEY,
FEATURE_ENABLED: {
CAMPAIGN: process.env.FEATURE_CAMPAIGN ?? false,
},
},
sentry: {
hideSourceMaps: true,
},
images: {
domains: [
process.env.IMAGE_HOST ?? 'localhost',
process.env.GHOST_API_URL?.replace('https://', '') || 'blog.podkrepi.bg',
],
},
async rewrites() {
return [
{
source: '/api/v1/:slug*',
destination: `${process.env.API_URL ?? 'http://localhost:5010/api/v1'}/:slug*`, // Proxy to API
},
{
source: '/robots.txt',
destination: '/api/robots',
},
]
},
async redirects() {
return [
{
source: '/profile',
destination: '/profile/donations',
permanent: false,
},
]
},
async headers() {
const securityHeaders = [
{
key: 'X-Frame-Options',
value: 'SAMEORIGIN',
},
{
key: 'X-XSS-Protection',
value: '1; mode=block',
},
]
return [
{
// Apply the headers to all routes
source: '/:path*',
headers: securityHeaders,
},
]
},
modularizeImports: {
lodash: {
transform: 'lodash/{{member}}',
},
'@mui/material': {
transform: '@mui/material/{{member}}',
},
'@mui/icons-material': {
transform: '@mui/icons-material/{{member}}',
},
'@mui/core/': {
transform: '@mui/core/{{member}}',
},
'@mui/lab/': {
transform: '@mui/lab/{{member}}',
},
},
}
const SentryWebpackPluginOptions = {
// Additional config options for the Sentry Webpack plugin. Keep in mind that
// the following options are set automatically, and overriding them is not
// recommended:
// release, url, org, project, authToken, configFile, stripPrefix,
// urlPrefix, include, ignore
// For all available options, see:
// https://github.com/getsentry/sentry-webpack-plugin#options.
debug: ['staging', 'production'].includes(process.env.APP_ENV) || false,
dryRun: ['development', 'nightly'].includes(process.env.APP_ENV) || true,
silent: true,
}
// Make sure adding Sentry options is the last code to run before exporting, to
// ensure that your source maps include changes from all other Webpack plugins
module.exports = withSentryConfig(moduleExports, SentryWebpackPluginOptions)
if (process.env.ANALYZE === 'true') {
const withBundleAnalyzer = require('@next/bundle-analyzer')({
enabled: process.env.ANALYZE === 'true',
})
module.exports = withBundleAnalyzer(module.exports)
}