-
-
Notifications
You must be signed in to change notification settings - Fork 113
/
next.config.js
111 lines (100 loc) · 3.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
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
require('dotenv').config();
const withSourceMaps = require('@zeit/next-source-maps')();
const withMDX = require('@next/mdx')({
extension: /\.mdx?$/,
});
const withPlugins = require('next-compose-plugins');
const withLess = require('@zeit/next-less');
const bundleAnalyzer = require('@next/bundle-analyzer');
const nextConfig = {
env: {
BASE_URL: process.env.BASE_URL,
FIREBASE_API_KEY: process.env.FIREBASE_API_KEY,
FIREBASE_AUTH_DOMAIN: process.env.FIREBASE_AUTH_DOMAIN,
FIREBASE_DATABASE_URL: process.env.FIREBASE_DATABASE_URL,
FIREBASE_PROJECT_ID: process.env.FIREBASE_PROJECT_ID,
FIREBASE_STORAGE_BUCKET: process.env.FIREBASE_STORAGE_BUCKET,
FIREBASE_MESSAGING_SENDER_ID:
process.env.FIREBASE_MESSAGING_SENDER_ID,
FIREBASE_APP_ID: process.env.FIREBASE_APP_ID,
PAYPAL_CLIENT_ID: process.env.PAYPAL_CLIENT_ID,
PAYPAL_CLIENT_SECRET: process.env.PAYPAL_CLIENT_SECRET,
STRIPE_CLIENT_ID: process.env.STRIPE_CLIENT_ID,
STRIPE_CLIENT_SECRET: process.env.STRIPE_CLIENT_SECRET,
STRIPE_WEBHOOK_SECRET: process.env.STRIPE_WEBHOOK_SECRET,
COUPON_SALT: process.env.COUPON_SALT,
COUPON_URL: process.env.COUPON_URL,
FIREBASE_ADMIN_UID: process.env.FIREBASE_ADMIN_UID,
DATABASE_TYPE: process.env.DATABASE_TYPE,
DATABASE_HOST: process.env.DATABASE_HOST,
DATABASE_PORT: process.env.DATABASE_PORT,
DATABASE_USERNAME: process.env.DATABASE_USERNAME,
DATABASE_PASSWORD: process.env.DATABASE_PASSWORD,
DATABASE_NAME: process.env.DATABASE_NAME,
DATABASE_SSL_CERTIFICATE: process.env.DATABASE_SSL_CERTIFICATE,
// same as in ...
GOOGLE_ANALYTICS: process.env.GOOGLE_ANALYTICS,
SENTRY_DSN: process.env.SENTRY_DSN,
REVUE_TOKEN: process.env.REVUE_TOKEN,
SLACK_TOKEN: process.env.SLACK_TOKEN,
CONVERTKIT_API_KEY: process.env.CONVERTKIT_API_KEY,
CONVERTKIT_FORM_ID: process.env.CONVERTKIT_FORM_ID,
S3_ENDPOINT: process.env.S3_ENDPOINT,
S3_ACCESS_KEY_ID: process.env.S3_ACCESS_KEY_ID,
S3_SECRET_ACCESS_KEY: process.env.S3_SECRET_ACCESS_KEY,
S3_BUCKET: process.env.S3_BUCKET,
},
webpack: (config, { isServer }) => {
// Less with Antd
// https://github.com/ant-design/ant-design/issues/15696#issuecomment-683440468
if (isServer) {
const antStyles = /antd\/.*?\/style.*?/;
const origExternals = [...config.externals];
config.externals = [
(context, request, callback) => {
if (request.match(antStyles)) return callback();
if (typeof origExternals[0] === 'function') {
origExternals[0](context, request, callback);
} else {
callback();
}
},
...(typeof origExternals[0] === 'function'
? []
: origExternals),
];
config.module.rules.unshift({
test: antStyles,
use: 'null-loader',
});
}
// MDX
if (!isServer) {
config.node = {
fs: 'empty',
};
}
// Sentry
if (!isServer) {
config.resolve.alias['@sentry/node'] = '@sentry/browser';
}
return config;
},
};
const lessWithAntdConfig = {
lessLoaderOptions: {
javascriptEnabled: true,
},
};
const withBundleAnalyzer = bundleAnalyzer({
enabled: process.env.ANALYZE === 'true',
});
module.exports = withPlugins(
[
[withLess, lessWithAntdConfig],
[withMDX],
[withSourceMaps],
[withBundleAnalyzer],
],
nextConfig
);