forked from launchdarkly/LaunchDarkly-Docs
-
Notifications
You must be signed in to change notification settings - Fork 0
/
gatsby-config.js
207 lines (202 loc) · 5.56 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
/* eslint-disable @typescript-eslint/no-var-requires */
const { queries } = require('./src/utils/algolia')
// These are useful to debug build issues
console.log(`
GATSBY_ACTIVE_ENV=${process.env.GATSBY_ACTIVE_ENV}
PR_NUMBER=${process.env.PR_NUMBER}
GATSBY_ALGOLIA_INDEX=${process.env.GATSBY_ALGOLIA_INDEX}
GATSBY_ALGOLIA_APP_ID=${process.env.GATSBY_ALGOLIA_APP_ID}
`)
const plugins = [
{
//https://www.gatsbyjs.org/packages/gatsby-plugin-segment-js/
resolve: 'gatsby-plugin-segment-js',
options: {
prodKey: process.env.SEGMENT_KEY,
//track pageviews when there is a route change. Calls window.analytics.page() on each route change.
trackPage: true,
delayLoad: false,
delayLoadTime: 1000,
},
},
{
resolve: 'gatsby-source-filesystem',
options: {
name: 'mdx-images',
path: `${__dirname}/src/content/images`,
},
},
{
resolve: 'gatsby-plugin-mdx',
options: {
remarkPlugins: [require('remark-slug')],
gatsbyRemarkPlugins: [
{
resolve: 'gatsby-remark-relative-images',
},
{
resolve: 'gatsby-remark-images',
options: {
maxWidth: 640,
showCaptions: true,
},
},
'gatsby-remark-copy-linked-files',
],
},
},
'gatsby-plugin-theme-ui',
{
resolve: 'gatsby-theme-style-guide',
options: {
// sets path for generated page
basePath: '/design-system',
},
},
'gatsby-plugin-react-helmet-async',
'gatsby-plugin-typescript',
'gatsby-transformer-json',
{
resolve: 'gatsby-plugin-sitemap',
options: {
exclude: ['/systemLayout/', '/components', '/design-system'],
},
},
{
resolve: 'gatsby-source-filesystem',
options: {
name: 'navigationData',
path: `${__dirname}/src/content/navigationData.json`,
},
},
{
resolve: 'gatsby-source-filesystem',
options: {
name: 'rootTopics',
path: `${__dirname}/autoGeneratedData/rootTopics.json`,
},
},
{
resolve: 'gatsby-source-filesystem',
options: {
name: 'secondLevelTopics',
path: `${__dirname}/autoGeneratedData/secondLevelTopics.json`,
},
},
{
resolve: 'gatsby-source-filesystem',
options: {
name: 'images',
path: `${__dirname}/assets/images`,
},
},
{
resolve: 'gatsby-source-filesystem',
options: {
path: `${__dirname}/src/content/topics`,
name: 'mdx',
},
},
{
resolve: 'gatsby-plugin-svgr-loader',
options: {
rule: {
options: {
svgoConfig: {
plugins: [
{ removeAttrs: { attrs: 'fill' } },
{
removeViewBox: false,
},
{
removeDimensions: true,
},
],
},
},
include: /icons/,
},
},
},
'gatsby-transformer-sharp',
'gatsby-plugin-sharp',
'gatsby-plugin-catch-links',
{
resolve: 'gatsby-plugin-manifest',
options: {
name: 'LaunchDarkly Docs',
short_name: 'LD Docs',
start_url: '/',
background_color: '#0E1932',
theme_color: '#FFF',
display: 'minimal-ui',
icon: 'assets/images/launchdarkly-logo.png', // This path is relative to the root of the site.
},
},
{
resolve: 'gatsby-plugin-google-analytics',
options: {
trackingId: 'UA-44750782-3',
head: true,
cookieDomain: 'launchdarkly.com',
},
},
{
resolve: 'gatsby-plugin-launchdarkly',
options: {
clientSideID:
process.env.GATSBY_ACTIVE_ENV === 'production' ? '5e44ab7d09107307fa78bd08' : '5e44ab7d09107307fa78bd09',
options: {
bootstrap: 'localstorage',
},
},
},
]
// Only build algolia indexes in staging and production
if (process.env.GATSBY_ACTIVE_ENV === 'staging' || process.env.GATSBY_ACTIVE_ENV === 'production') {
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
},
})
}
// Only use gatsby-plugin-s3 when deploying to production because it does not support
// pushing to s3 subfolders.
// Staging deploy uses a github action called s3-sync-action to push to a subfolder
// in the staging bucket
if (process.env.GATSBY_ACTIVE_ENV === 'production') {
const gatsbyPluginS3 = {
resolve: 'gatsby-plugin-s3',
options: {
bucketName: process.env.AWS_S3_BUCKET,
protocol: 'https',
hostname: process.env.AWS_HOSTNAME,
generateRedirectObjectsForPermanentRedirects: true,
enableS3StaticWebsiteHosting: false,
},
}
plugins.push(gatsbyPluginS3)
} else if (process.env.GATSBY_ACTIVE_ENV === 'staging') {
// GOTCHA: On staging, the client side redirect plugin auto-generates index.html files
// which acts as default pages which contains scripts to enforce redirects defined in
// gatsby-node.js. Production don't need this because gatsby-plugin-s3 does this for us
// automatically
plugins.push('gatsby-plugin-client-side-redirect')
}
module.exports = {
// Push pr branches to a subfolder in the staging bucket using the pr number as routes.
// For example, a pr number 58 will be previewable on:
// https://docs.staging.launchdarkly.com/58
pathPrefix: process.env.GATSBY_ACTIVE_ENV === 'staging' ? `/${process.env.PR_NUMBER}` : '/',
siteMetadata: {
title: 'LaunchDarkly Docs',
description: 'LaunchDarkly documentation',
author: '@launchdarkly',
siteUrl: 'https://docs.launchdarkly.com',
},
plugins,
}