-
Notifications
You must be signed in to change notification settings - Fork 21
/
next.config.js
154 lines (148 loc) · 3.77 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
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
/**
* @type {import('next').NextConfig}
*/
/* eslint-disable @typescript-eslint/no-var-requires */
const BundleAnalyzer = require('next-bundle-analyzer');
const esmModules = require('./next.base').esmModules;
const config = {
poweredByHeader: false,
eslint: {
// add background and serverless to the default list of pages for eslint
dirs: ['pages', 'components', 'lib', 'background', 'serverless', 'stories'],
ignoreDuringBuilds: true
},
// types are tested separately from the build
typescript: {
ignoreBuildErrors: true,
tsconfigPath: 'tsconfig.next.json'
},
compiler: {
styledComponents: true
},
experimental: {
esmExternals: false,
webpackBuildWorker: true
// turbo: {
// resolveAlias: {
// fs: false
// },
// rules: {
// '*.svg': {
// loaders: ['@svgr/webpack'],
// as: '*.js'
// }
// }
// }
},
images: {
// next image is broken in staging/production as of 14.0.1
unoptimized: true
},
transpilePackages: esmModules,
modularizeImports: {
lodash: {
transform: 'lodash/{{member}}'
}
},
assetPrefix: process.env.REACT_APP_APP_ENV === 'production' ? 'https://cdn.charmverse.io' : undefined,
productionBrowserSourceMaps: true,
async redirects() {
return [
{
source: '/:domain(^(?!.*\bapi\b).*$)/settings/:path*',
destination: '/:domain',
permanent: true
},
{
source: '/:domain(^(?!.*\bapi\b).*$)/settings',
destination: '/:domain',
permanent: true
},
{
source: '/nexus',
destination: '/',
permanent: true
},
{
source: '/profile',
destination: '/',
permanent: true
},
{
source: '/u/:path*',
destination: '/',
permanent: true
},
{
source: '/integrations',
destination: '/',
permanent: true
},
{
// strip out old /share prefix
source: '/share/:path*',
destination: '/:path*',
permanent: true
},
// added 4/2023 to redirect old /createWorkspace to /createSpace
{
source: '/createWorkspace',
destination: '/createSpace',
permanent: true
},
// added 4/2023 to redirect /signup to /createSpace
{
source: '/signup',
destination: '/createSpace',
permanent: true
},
// added 11/2023 to redirect old /bounties route to /rewards
{
source: '/:domain/bounties',
destination: '/:domain/rewards',
permanent: true // change this to true once we confirm success :)
}
];
},
webpack(_config) {
// Fix for: "Module not found: Can't resolve 'canvas'"
_config.resolve.alias.canvas = false;
_config.module.rules.push({
test: /\.svg$/,
use: [
{
loader: '@svgr/webpack',
options: {
svgoConfig: {
// dont remove viewBox which allows svg to scale properly
plugins: [
{
name: 'preset-default',
params: {
overrides: { removeViewBox: false }
}
}
]
}
}
}
]
});
return _config;
}
};
/**
* Remove undefined values so Next.js doesn't complain during serialization
*/
const removeUndefined = (obj) => {
const newObj = {};
Object.keys(obj).forEach((key) => {
if (obj[key] === Object(obj[key])) newObj[key] = removeUndefined(obj[key]);
else if (obj[key] !== undefined) newObj[key] = obj[key];
});
return newObj;
};
const withBundleAnalyzer = BundleAnalyzer({
enabled: process.env.ANALYZE === 'true'
});
module.exports = withBundleAnalyzer(config);