-
Notifications
You must be signed in to change notification settings - Fork 0
/
static.config.js
77 lines (67 loc) · 2.34 KB
/
static.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
/* eslint-disable no-console */
import "dotenv/config"; // Load environment variables from .env
import React from "react";
// Typescript support in static.config.js is not yet supported, but is coming in a future update!
(function checkForRequiredEnvironmentVariables() {
const alwaysRequiredEnvVars = ["API_ROOT"];
const oauthEnvVars = [
"AUTH0_DOMAIN",
"AUTH0_CLIENT_ID",
"AUTH0_BACKEND_API_IDENTIFIER",
];
const requiredEnvVars =
process.env.NODE_ENV === "production"
? [...alwaysRequiredEnvVars, ...oauthEnvVars, "FRONTEND_PROD_SITE_ROOT"]
: [...alwaysRequiredEnvVars];
const optionalEnvVars =
process.env.NODE_ENV === "production"
? ["FRONTEND_PROD_BASE_PATH"]
: [...oauthEnvVars, "FRONTEND_MOCK_API_SERVER"];
const isUnsetEnvVar = (key) => [undefined, ""].includes(process.env[key]);
const missingEnvVars = requiredEnvVars.filter(isUnsetEnvVar);
const missingOptionalEnvVars = optionalEnvVars.filter(isUnsetEnvVar);
if (missingEnvVars.length > 0) {
const lines = [
"The following environment variables are required:",
...missingEnvVars.map((str) => `- ${str}`),
"",
];
console.error(lines.join("\n"));
process.exit(1);
}
if (missingOptionalEnvVars.length > 0) {
const lines = [
"Optional environment variables that you can set:",
...missingOptionalEnvVars.map((str) => `- ${str}`),
"",
];
console.warn(lines.join("\n"));
}
})();
export default {
// eslint-disable-next-line react/prop-types
Document: ({ Html, Head, Body, children }) => (
<Html lang="en-US">
<Head>
<meta charSet="utf-8" />
<title>Instrument Catalog</title>
<meta name="viewport" content="width=device-width, initial-scale=1" />
</Head>
<Body>{children}</Body>
</Html>
),
entry: "index.tsx", // Relative to paths.src
plugins: [
["react-static-plugin-typescript", { typeCheck: false }], // Lint separately
["react-static-plugin-source-filesystem", { location: "./src/pages" }],
"react-static-plugin-reach-router",
"react-static-plugin-sitemap",
"react-static-plugin-styled-components",
],
// Dynamic configuration
devServer: {
port: Number(process.env.FRONTEND_DEVSERVER_PORT) || 5000,
},
siteRoot: process.env.FRONTEND_PROD_SITE_ROOT,
basePath: process.env.FRONTEND_PROD_BASE_PATH,
};