forked from microreact/server
-
Notifications
You must be signed in to change notification settings - Fork 0
/
next.config.js
93 lines (77 loc) · 2.19 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
const fs = require("fs");
const path = require("path");
// const withPlugins = require('next-compose-plugins');
// const modules = [
// 'microreact-viewer',
// "@phylocanvas/phylocanvas.gl",
// "kepler.gl",
// ]
// const withTM = require('next-transpile-modules')(modules);
function getServerRuntimeConfig() {
const mergeOptions = require("merge-options");
const serverRuntimeConfig = require("./defaults.json");
const configFilePath = process.env.CONFIG_FILE || path.resolve(__dirname, "config.json");
if (fs.existsSync(configFilePath)) {
return mergeOptions(serverRuntimeConfig, require(configFilePath));
}
else {
return serverRuntimeConfig;
}
}
function getPublicRuntimeConfig(serverRuntimeConfig) {
const packageJson = require("./package.json");
return {
version: packageJson.version,
mapboxApiAccessToken: serverRuntimeConfig.mapboxApiAccessToken,
downloadActions: serverRuntimeConfig.downloadActions,
baseUrl: serverRuntimeConfig.baseUrl,
customShowcase: serverRuntimeConfig.showcaseFolders?.length > 0,
};
}
const serverRuntimeConfig = getServerRuntimeConfig();
module.exports.serverRuntimeConfig = serverRuntimeConfig;
const publicRuntimeConfig = getPublicRuntimeConfig(serverRuntimeConfig);
module.exports.publicRuntimeConfig = publicRuntimeConfig;
module.exports = ({
reactStrictMode: true,
swcMinify: true,
experimental: {
// images: { unoptimized: true },
},
// Will only be available on the server side
serverRuntimeConfig,
// Will be available on both server and client
publicRuntimeConfig,
async rewrites() {
return [
{
source: "/accept-invitation/:token",
destination: "/api/shares/accept",
},
];
},
async redirects() {
return [
{
source: "/showcase",
destination: "/",
permanent: false,
},
{
source: "/myaccount",
destination: "/my-account",
permanent: false,
},
{
source: "/api/files/get",
destination: "/api/files/raw",
permanent: false,
},
{
source: "/api/files/local",
destination: "/api/files/raw",
permanent: false,
},
];
},
});