-
Notifications
You must be signed in to change notification settings - Fork 1
/
gatsby-config.js
172 lines (156 loc) · 4.21 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
const _ = require('lodash')
const AWS = require('aws-sdk')
// If we detect if we're running in a CI environment, only a few sample
// photos will be downloaded from a test bucket, rather the the full
// high-resolution photos displayed in production. This is simply to
// save on AWS costs :)
const GatsbyEnv = {
Development: 'Development',
Production: 'Production',
Staging: 'Staging',
}
const getSourceS3ConfigForEnvironment = env => {
switch (_.startCase(env)) {
// TODO: Re-add this after minio.jesses.io is set back up.
case GatsbyEnv.Development:
return {
bucketName: 'js-photos-dev',
domain: 'minio.jesses.io',
}
case GatsbyEnv.Staging: {
return { bucketName: 'js-photos-dev' }
}
case GatsbyEnv.Production: {
return { bucketName: 'jesse.pics', protocol: 'http' }
}
}
}
const GATSBY_ENV = _.startCase(GatsbyEnv[process.env.GATSBY_ENV])
const AUTHOR_NAME = 'Jesse Stuart'
const SITE_NAME = 'jesses.io'
const IS_LOCAL = GATSBY_ENV === GatsbyEnv.Development
const siteMetadata = {
author: AUTHOR_NAME,
description: 'I build things and thoughts.',
siteUrl: `https://${SITE_NAME}`,
title: AUTHOR_NAME,
}
const sourceFilesystem = {
resolve: 'gatsby-source-filesystem',
options: {
path: `${__dirname}/src/pages`,
name: 'pages',
},
}
const sourceFilesystemImages = {
resolve: 'gatsby-source-filesystem',
options: {
path: `${__dirname}/src/images`,
name: 'images',
},
}
const transformerRemark = {
resolve: 'gatsby-transformer-remark',
options: {
plugins: [
{
resolve: 'gatsby-remark-images',
options: {
maxWidth: 768,
},
},
'gatsby-remark-autolink-headers',
'gatsby-remark-copy-linked-files',
'gatsby-remark-prismjs',
'gatsby-remark-smartypants',
],
},
}
const googleAnalyticsPlugin = {
resolve: 'gatsby-plugin-google-analytics',
options: {
trackingId: 'UA-113515971-1',
},
}
const ACCESS_KEY_ID = IS_LOCAL
? process.env.MINIO_ACCESS_KEY
: process.env.AWS_ACCESS_KEY
const SECRET_KEY_ID = IS_LOCAL
? process.env.MINIO_SECRET_KEY
: process.env.AWS_SECRET_KEY
AWS.config.update({
accessKeyId: ACCESS_KEY_ID,
secretAccessKey: SECRET_KEY_ID,
})
const sourceS3 = {
resolve: 'gatsby-source-s3-image',
options: getSourceS3ConfigForEnvironment(GATSBY_ENV),
}
const layoutPlugin = {
resolve: 'gatsby-plugin-layout',
}
/* eslint-disable @typescript-eslint/camelcase */
const manifestPlugin = {
resolve: 'gatsby-plugin-manifest',
options: {
name: 'Jesse Stuart',
short_name: 'jesses.io',
start_url: '/',
background_color: '#373b46',
theme_color: '#673ab7',
display: 'standalone',
icon: './src/components/Icons/logo_dark.svg',
},
}
/* eslint-enable @typescript-eslint/camelcase */
let plugins = _.compact([
'gatsby-plugin-typescript',
'gatsby-plugin-theme-ui',
'gatsby-plugin-root-import',
// ====================================
// Gotta load those sweet, sweet files.
// ====================================
sourceFilesystem,
sourceFilesystemImages,
sourceS3,
layoutPlugin,
// =======================================================================
// Add in React Helmet and React 16 support until Gatsby v2 is released.
// =======================================================================
'gatsby-plugin-react-helmet',
// ========================
// Styling-related plugins.
// ========================
'gatsby-plugin-styled-components',
// typographyPlugin,
// ==========================================
// Transformers for Markdown and image files.
// ==========================================
'gatsby-plugin-sharp',
'gatsby-transformer-sharp',
transformerRemark,
// ==========
// Analytics.
// ==========
googleAnalyticsPlugin,
// ===========
// Miscellany.
// ===========
'gatsby-plugin-remove-trailing-slashes',
'gatsby-plugin-lodash',
])
if (!IS_LOCAL) {
//=================================
// Production/Staging-only plugins.
//=================================
plugins = _.concat(plugins, [
// 'gatsby-plugin-offline',
manifestPlugin,
'gatsby-plugin-netlify',
'gatsby-plugin-netlify-cache',
])
}
module.exports = {
siteMetadata,
plugins,
}