This repository was archived by the owner on Mar 25, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathnext.config.js
121 lines (99 loc) · 3.24 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
112
113
114
115
116
117
118
119
120
121
const process = require("process");
const withPlugins = require("next-compose-plugins");
const aliasConfig = require("./plugins/aliasConfig");
const transpileModulesConfig = require("./plugins/transpileModulesConfig");
const withIgnoreFs = require("./plugins/withIgnoreFs");
const { makePages, EXPORT_PATH_MAP } = require("./compile/makePages");
const { makeCasts, getCastManifest } = require("./compile/makeCasts");
const customizeTOC = require("./plugins/rehype-plugins/customizeTOC");
const injectAsciicasts = require("./plugins/rehype-plugins/injectAsciicasts");
const splitgraphRehypePrism = require("./plugins/rehype-plugins/splitgraphRehypePrism");
const fs = require("fs").promises;
makePages();
const { castManifest } = makeCasts();
// console.log("Casts:");
for (let castKey of Object.keys(castManifest)) {
console.log(" ", castKey);
}
const IGNORE_BUILD_ERRORS = process.env.IGNORE_BUILD_ERRORS === "true";
if (IGNORE_BUILD_ERRORS) {
console.warn("Suppressing next.js typecheck...");
}
const nextConfig = {
typescript: {
ignoreBuildErrors: IGNORE_BUILD_ERRORS,
},
experimental: {
externalDir: true,
},
env: {
// This is a build time config variable, but in practice, since we should
// only have one website deployed accessible to search engines, that's okay.
SEO_CANONICAL_BASE_URL:
process.env.SEO_CANONICAL_BASE_URL || `https://www.splitgraph.com`,
// This is a relative URL but is appended to window origin on load
MATOMO_RELATIVE_URL: "/scripts/js",
MATOMO_JS_FILE: "",
MATOMO_PHP_FILE: "",
MATOMO_SITE_ID: "1",
DOCSEARCH_JS_URL:
process.env.DOCSEARCH_JS_URL ||
"https://cdn.jsdelivr.net/npm/docsearch.js@2/dist/cdn/docsearch.min.js",
DOCSEARCH_CSS_URL:
process.env.DOCSEARCH_CSS_URL ||
"https://cdn.jsdelivr.net/npm/docsearch.js@2/dist/cdn/docsearch.min.css",
DOCSEARCH_PUBLIC_CLIENT_API_KEY:
process.env.DOCSEARCH_PUBLIC_CLIENT_API_KEY,
DOCSEARCH_INDEX_NAME: process.env.DOCSEARCH_INDEX_NAME || "splitgraph",
},
// resolve: {
// alias: aliasConfig,
// },
exportPathMap: async () => {
try {
const jsonMap = await fs.readFile(EXPORT_PATH_MAP);
return JSON.parse(jsonMap);
} catch (_) {
console.warn("No exportPathMap found");
return {};
}
},
};
const _configs = {
transpileModules: transpileModulesConfig,
css: {},
mdx: {
options: {
remarkPlugins: [
[require("remark-disable-tokenizers"), { block: ["indentedCode"] }],
require("remark-sectionize"),
],
rehypePlugins: [
splitgraphRehypePrism,
[injectAsciicasts, { castManifest }],
require("rehype-slug"),
[
require("rehype-toc"),
{
customizeTOC,
},
],
],
},
},
bundleAnalyzer: {
enabled: process.env.ANALYZE === "true",
},
};
const _plugins = {
bundleAnalyzer: require("@next/bundle-analyzer"),
mdx: require("@next/mdx")(_configs.mdx), // note slightly different call format
};
const plugins = [
[_plugins.mdx],
// [_plugins.withIgnoreFs, {}],
// [_plugins.css, _configs.css],
// [_plugins.bundleAnalyzer(_configs.bundleAnalyzer)],
];
// module.exports = nextConfig;
module.exports = withPlugins(plugins, nextConfig);