This repository has been archived by the owner on Aug 29, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathnext.config.js
132 lines (124 loc) · 4.09 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
// Use the SentryWebpack plugin to upload the source maps during build step
const SentryWebpackPlugin = require('@sentry/webpack-plugin');
const { withSentryConfig } = require('@sentry/nextjs');
const withBundleAnalyzer = require('@next/bundle-analyzer')({
enabled: process.env.ANALYZE === 'true',
});
const {
NEXT_PUBLIC_SENTRY_DSN: SENTRY_DSN,
VERCEL_GITHUB_COMMIT_SHA,
SANITY_GRAPHQL_URL,
} = process.env;
const COMMIT_SHA = VERCEL_GITHUB_COMMIT_SHA;
process.env.SENTRY_DSN = SENTRY_DSN;
const basePath = '';
const defaultConfig = {
productionBrowserSourceMaps: true,
env: {
NEXT_PUBLIC_COMMIT_SHA: COMMIT_SHA,
SANITY_PROJECT_ID: process.env.NEXT_PUBLIC_SANITY_PROJECT_ID,
SANITY_DATASET: process.env.NEXT_PUBLIC_SANITY_DATASET,
SANITY_STUDIO_PREVIEW_SECRET: process.env.SANITY_STUDIO_PREVIEW_SECRET,
CLOUDINARY_API_KEY: process.env.CLOUDINARY_API_KEY,
CLOUDINARY_API_SECRET: process.env.CLOUDINARY_API_SECRET,
NEXT_PUBLIC_CLOUDINARY_CLOUD_NAME: process.env.CLOUD_NAME,
CLOUD_NAME: process.env.CLOUD_NAME,
SANITY_GRAPHQL_URL: SANITY_GRAPHQL_URL,
},
images: {
domains: ['res.cloudinary.com', 'cdn.sanity.io'],
unoptimized: true,
},
publicRuntimeConfig: {
// Will be available on both server and client
staticFolder: '/static',
mixPanelToken: process.env.MIXPANEL_TOKEN,
},
async headers() {
return [
{
// enabling CORs for in studio subscription to changes
source: '/post/liveEdit/:path*',
headers: [
{ key: 'Access-Control-Allow-Credentials', value: 'true' },
{ key: 'Access-Control-Allow-Origin', value: '*' },
{
key: 'Access-Control-Allow-Methods',
value: 'GET,OPTIONS,PATCH,DELETE,POST,PUT',
},
{
key: 'Access-Control-Allow-Headers',
value:
'X-CSRF-Token, X-Requested-With, Accept, Accept-Version, Content-Length, Content-MD5, Content-Type, Date, X-Api-Version',
},
],
},
];
},
async redirects() {
const customPeriodRewrites = [
'/post/create-a-restaurant-qr-code-menu-in-next.js',
'/post/blur-faces-in-images-in-next.js',
"/post/create-a-youtube-like-'click-to-unmute'-feature-in-nuxt.js",
'/post/create-a-contact-card-barcode-generator-in-next.js',
'/post/create-custom-video-ads-with-text-and-image-in-next.js',
];
return [
...customPeriodRewrites.map((path) => ({
source: `${path}(.*)`,
destination: path.replace(/\./g, '-'),
permanent: false,
})),
{
source: '/post/:path*',
destination: 'https://cloudinary.com/blog/guest_post/:path*',
permanent: false,
},
{
source: '/author/:path*',
destination: 'https://cloudinary.com/blog/author/:path*',
permanent: true,
},
{
source: '/',
destination: 'https://cloudinary.com/blog',
permanent: true,
},
{
source: '/docs/:path*',
destination: 'https://cloudinary.com',
permanent: true,
},
];
},
webpack: (config, { buildId, dev, isServer, defaultLoaders, webpack }) => {
if (!isServer) {
config.resolve.fallback.fs = false;
}
// SVG LOADER
config.module.rules.push({
test: /\.svg$/,
use: ['@svgr/webpack'],
});
return config;
},
basePath,
};
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
silent: true, // Suppresses all logs
// For all available options, see:
// https://github.com/getsentry/sentry-webpack-plugin#options.
};
/**
* Export w/ defaultConfig
*/
// 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 = withBundleAnalyzer(
withSentryConfig(defaultConfig, SentryWebpackPluginOptions),
);