-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathnext.config.js
77 lines (74 loc) · 2.36 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
// This file sets a custom webpack configuration to use your Next.js app
// with Sentry.
// https://nextjs.org/docs/api-reference/next.config.js/introduction
// https://docs.sentry.io/platforms/javascript/guides/nextjs/
const { withSentryConfig } = require('@sentry/nextjs');
const path = require('path');
const withBundleAnalyzer = require('@next/bundle-analyzer')({
enabled: process.env.ANALYZE === 'true',
});
const withLess = require('next-with-less');
const { version } = require('./package.json');
const isProd = process.env.NODE_ENV === 'production';
const nextConfig = (phase) => {
const env = {
NEXT_PUBLIC_ENV: process.env.NEXT_PUBLIC_ENV,
NEXT_PUBLIC_STORAGE_PREFIX: process.env.NEXT_PUBLIC_STORAGE_PREFIX,
NEXT_PUBLIC_API_HOST: process.env.NEXT_PUBLIC_API_HOST,
NEXT_PUBLIC_SENTRY_DSN: process.env.NEXT_PUBLIC_SENTRY_DSN,
};
/** @type {import('next').NextConfig} */
const config = {
output: 'standalone',
reactStrictMode: true,
poweredByHeader: false,
productionBrowserSourceMaps: true,
env,
compress: isProd,
transpilePackages: ['antd', '@ant-design', 'rc-util', 'rc-pagination', 'rc-picker'],
publicRuntimeConfig: env,
compiler: {
// Remove `console.*` output except `console.error`
removeConsole: isProd
? {
exclude: ['error'],
}
: false,
// Uncomment this to suppress all logs.
// removeConsole: true,
},
lessLoaderOptions: {
// cssModules: true,
lessOptions: {
javascriptEnabled: true,
modifyVars: {},
},
},
// Disable css--modules component styling
webpack(config) {
// Source: https://cwtuan.blogspot.com/2022/10/disable-css-module-in-nextjs-v1231-sept.html
config.module.rules.forEach((rule) => {
const { oneOf } = rule;
if (oneOf) {
oneOf.forEach((one) => {
if (!`${one.issuer?.and}`.includes('_app')) return;
one.issuer.and = [path.resolve(__dirname)];
});
}
});
return config;
},
experimental: {
webpackBuildWorker: true,
},
};
return withBundleAnalyzer(
withSentryConfig(withLess(config), {
debug: !isProd,
hideSourceMaps: true,
environment: process.env.NODE_ENV,
release: `parsec-next-app-${process.env.NODE_ENV}@${version}`,
}),
);
};
module.exports = nextConfig;