-
Notifications
You must be signed in to change notification settings - Fork 1
/
next.config.mjs
77 lines (63 loc) · 1.84 KB
/
next.config.mjs
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
import * as dotenv from 'dotenv';
import withAnalyzer from '@next/bundle-analyzer';
dotenv.config();
const withBundleAnalyzer = withAnalyzer({
enabled: process.env.ANALYZE === 'true',
});
const transpileDependencies = [];
const nextConfig = {
compiler: {
styledComponents: true,
},
webpack: (config, { isServer }) => {
// add polyfills to all browsers
const originalEntry = config.entry;
// hide warnings https://github.com/vercel/next.js/discussions/30870#discussioncomment-1862620
config.infrastructureLogging = {
level: 'error',
};
// Fixes npm packages that depend on `fs`, `net`, `tls` modules
if (!isServer) {
config.resolve.fallback = {
fs: false,
net: false,
tls: false,
};
}
config.entry = async () => {
const entries = await originalEntry();
if (entries['main.js'] && !entries['main.js'].includes('./client/polyfills.js')) {
entries['main.js'].unshift('./client/polyfills.js');
}
return entries;
};
config.module.rules.unshift({
test: /\.(tsx|ts|js|mjs|jsx)$/,
include: new RegExp(`node_modules/(${transpileDependencies.join('|')})`),
});
config.module.rules.push({
test: /\.(graphql|gql)$/,
exclude: /node_modules/,
loader: 'graphql-tag/loader',
});
config.module.rules.push({
test: /\.svg$/i,
issuer: /\.(tsx|ts|js|mjs|jsx)$/,
use: ['@svgr/webpack'],
});
return config;
},
eslint: {
ignoreDuringBuilds: true,
},
env: {
ASSET_HOST: process.env.ASSET_HOST || '',
API_URL: process.env.API_URL,
PRINT_HTTP_REQUEST_LOGS: process.env.PRINT_HTTP_REQUEST_LOGS,
},
};
/** @type {import('next').NextConfig} */
export default () => {
const plugins = [withBundleAnalyzer];
return plugins.reduce((acc, next) => next(acc), nextConfig);
};