forked from getsentry/sentry-docs
-
Notifications
You must be signed in to change notification settings - Fork 0
/
gatsby-config.js
218 lines (209 loc) · 5.52 KB
/
gatsby-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
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
const axios = require("axios");
require("ts-node").register({
files: true, // to that TS node hooks have access to local typings too
});
const activeEnv =
process.env.GATSBY_ENV || process.env.NODE_ENV || "development";
console.log(`Using environment config: '${activeEnv}'`);
require("dotenv").config({
path: `.env.${activeEnv}`,
});
if (
process.env.VERCEL_GITHUB_COMMIT_REF === "master" &&
process.env.ALGOLIA_ADMIN_KEY
) {
process.env.ALGOLIA_INDEX = "1";
}
const queries = require("./src/utils/algolia");
const packages = new (require("./src/utils/packageRegistry"))();
const getPlugins = () => {
const remarkPlugins = [
{
resolve: require.resolve("./plugins/gatsby-remark-variables"),
options: {
scope: {
packages,
},
excludeExpr: ["default"],
},
},
{
resolve: `gatsby-remark-copy-linked-files`,
},
{
resolve: `gatsby-remark-autolink-headers`,
options: {
className: "anchor",
icon: `<svg viewBox="0 0 24 24" xmlns="http://www.w3.org/2000/svg"><path d="M10.879 6.05L15 1.93A5.001 5.001 0 0 1 22.071 9l-4.121 4.121a1 1 0 0 1-1.414-1.414l4.12-4.121a3 3 0 1 0-4.242-4.243l-4.121 4.121a1 1 0 1 1-1.414-1.414zm2.242 11.9L9 22.07A5 5 0 1 1 1.929 15l4.121-4.121a1 1 0 0 1 1.414 1.414l-4.12 4.121a3 3 0 1 0 4.242 4.243l4.121-4.121a1 1 0 1 1 1.414 1.414zm-8.364-.122l13.071-13.07a1 1 0 0 1 1.415 1.414L6.172 19.242a1 1 0 1 1-1.415-1.414z" fill="currentColor"></path></svg>`,
enableCustomId: true,
},
},
{
resolve: `gatsby-remark-images`,
options: {
maxWidth: 1200,
linkImagesToOriginal: true,
},
},
{
resolve: "gatsby-remark-prismjs",
options: {
noInlineHighlight: true,
},
},
// {
// resolve: `gatsby-remark-check-links`
// }
];
const plugins = [
{
resolve: "@sentry/gatsby",
options: {
dsn: process.env.SENTRY_DSN,
release: process.env.SENTRY_RELEASE,
tracesSampleRate: activeEnv === "development" ? 0 : 1,
},
},
"gatsby-plugin-sharp",
"gatsby-plugin-sass",
"gatsby-plugin-zeit-now",
{
resolve: `gatsby-transformer-remark`,
options: {
plugins: remarkPlugins,
},
},
{
resolve: "gatsby-plugin-mdx",
options: {
remarkPlugins: [require("remark-deflist")],
gatsbyRemarkPlugins: [
{
resolve: require.resolve("./plugins/gatsby-plugin-code-tabs"),
},
{
resolve: require.resolve("./plugins/gatsby-plugin-include"),
},
...remarkPlugins,
],
},
},
"gatsby-plugin-react-helmet",
`gatsby-transformer-yaml`,
{
resolve: `gatsby-transformer-json`,
options: {
typeName: ({ node }) => {
if (node.sourceInstanceName === "api") {
return "ApiEndpoint";
}
return null;
},
},
},
`gatsby-transformer-javascript-frontmatter`,
{
resolve: `gatsby-source-filesystem`,
options: {
name: `docs`,
path: `${__dirname}/src/docs`,
},
},
{
resolve: `gatsby-source-filesystem`,
options: {
name: `platforms`,
path: `${__dirname}/src/platforms`,
},
},
{
resolve: `gatsby-source-filesystem`,
options: {
name: `api`,
path: `${__dirname}/src/api`,
},
},
{
resolve: `gatsby-source-filesystem`,
options: {
name: `includes`,
path: `${__dirname}/src/includes`,
},
},
{
resolve: `gatsby-source-filesystem`,
options: {
name: `wizard`,
path: `${__dirname}/src/wizard`,
ignore: [`**/README.md`],
},
},
{
resolve: `gatsby-source-filesystem`,
options: {
name: `pages`,
path: `${__dirname}/src/pages`,
},
},
{
resolve: `gatsby-source-filesystem`,
options: {
name: "data",
path: `${__dirname}/src/data`,
},
},
{
resolve: "./plugins/gatsby-plugin-sentry-wizard",
options: {
source: "wizard",
output: `${__dirname}/public/_platforms`,
},
},
{
resolve: "./plugins/gatsby-redirects",
options: {
inputConfigFile: `${__dirname}/nginx.conf`,
outputConfigFile: `${__dirname}/nginx.out.conf`,
},
},
{
resolve: "./plugins/gatsby-plugin-openapi",
options: {
name: "openapi",
resolve: async () => {
const response = await axios.get(
"https://raw.githubusercontent.com/getsentry/sentry-api-schema/68bb79acfbbee062bd8d2f71ee3a07d43dc934c9/openapi-derefed.json"
);
return response.data;
},
// required, function which returns a Promise resolving Swagger JSON
},
},
// generate normal redirects so when you're running without nginx
// you receive similar behavior
`gatsby-plugin-meta-redirect`,
];
if (process.env.ALGOLIA_INDEX === "1") {
plugins.push({
resolve: `gatsby-plugin-algolia`,
options: {
appId: process.env.GATSBY_ALGOLIA_APP_ID,
apiKey: process.env.ALGOLIA_ADMIN_KEY,
queries,
chunkSize: 10000, // default: 1000
},
});
}
return plugins;
};
module.exports = {
// pathPrefix: `/develop`,
siteMetadata: {
title: "Sentry Documentation",
homeUrl: "https://docs.sentry.io",
sitePath: "docs.sentry.io",
description: "",
author: "@getsentry",
},
plugins: getPlugins(),
};