forked from rwieruch/nextjs-firebase-authentication
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathnext.config.js
72 lines (63 loc) · 1.96 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
//github.com/zeit/next.js/blob/canary/examples/with-ant-design-less/next.config.js
require('dotenv').config();
const fs = require('fs');
const path = require('path');
const withPlugins = require('next-compose-plugins');
const withLess = require('@zeit/next-less');
const lessToJS = require('less-vars-to-js');
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,
},
};
const lessWithAntdConfig = {
lessLoaderOptions: {
javascriptEnabled: true,
modifyVars: lessToJS(
fs.readFileSync(
path.resolve(__dirname, './assets/antd-custom.less'),
'utf8'
)
),
},
webpack: (config, { isServer }) => {
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',
});
}
return config;
},
};
const withBundleAnalyzer = bundleAnalyzer({
enabled: process.env.ANALYZE === 'true',
});
module.exports = withPlugins(
[[withLess, lessWithAntdConfig], [withBundleAnalyzer]],
nextConfig
);