-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgatsby-config.js
139 lines (132 loc) · 3.94 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
/* eslint-disable no-multi-spaces */
/* eslint-disable import/no-extraneous-dependencies */
/*
dotenv package is included by Gatsby
2 files need to be present in the project's root directory,
.env.development and .env.production and they must contain the following:
# DatoCMS
GATSBY_DATOCMS_FULL_ACCESS_TOKEN=yourFullAccessToken
GATSBY_DATOCMS_READ_ONLY_ACCESS_TOKEN=yourReadOnlyAccessToken
# Google Analytics
GATSBY_GA_TRACKING_ID=yourGaTrackingId
GATSBY_GA_OPTIMIZE_ID=yourGaOptimizeId
GATSBY_GA_EXPERIMENT_ID=yourGaExperimentId
GATSBY_GA_VARIATION_ID=yourGaVariationId
# Heap Analytics
GATSBY_HA_APP_ID=yourHaAppId
*/
require('dotenv').config({
path: `.env.${process.env.NODE_ENV}`,
});
/*
DatoCMS
We can read/write or just read the following end points:
1. Content Delivery API -> GraphQL Endpoint: https://graphql.datocms.com
2. Content Delivery API with draft content -> GraphQL Endpoint: https://graphql.datocms.com/preview
3. Content Management API -> REST Endpoint: https://site-api.datocms.com/* (not used)
*/
const hasFullAccess = false;
// eslint-disable-next-line no-unused-vars
const datocmsOptions = {
apiToken: hasFullAccess
? process.env.GATSBY_DATOCMS_FULL_ACCESS_TOKEN
: process.env.GATSBY_DATOCMS_READ_ONLY_ACCESS_TOKEN,
previewMode: false,
disableLiveReload: true,
};
// Google Analytics
const gaOptions = {
trackingId: process.env.GATSBY_GA_TRACKING_ID,
// Defines where to place the tracking script - 'true' in the head and 'false' in the body
head: false,
anonymize: true,
// Respect “Do Not Track”
respectDNT: true,
optimizeId: process.env.GATSBY_GA_OPTIMIZE_ID,
experimentId: process.env.GATSBY_GA_EXPERIMENT_ID,
variationId: process.env.GATSBY_GA_VARIATION_ID,
};
// Heap Analytics
const haOptions = {
appId: process.env.GATSBY_HA_APP_ID,
enableOnDevMode: false,
};
module.exports = {
siteMetadata: {
title: 'OCW',
description: 'OCW Progressive Web Application',
author: 'Daniel Seaton and Jean-Michel Claus',
},
plugins: [
{
resolve: 'gatsby-source-filesystem',
options: {
name: 'images',
path: `${__dirname}/src/images`,
},
},
'gatsby-transformer-sharp',
'gatsby-plugin-sharp',
{
resolve: 'gatsby-plugin-sass',
options: {
includePaths: ['./node_modules'],
},
},
{
resolve: 'gatsby-plugin-manifest',
// https://developers.google.com/web/fundamentals/web-app-manifest/
options: {
name: 'MIT OpenCourseWare', // Used in app install prompt
short_name: 'OCW', // Used in home screen or launcher
start_url: '/',
background_color: '#a31f34', // MIT colors: http://web.mit.edu/graphicidentity/colors.html
theme_color: '#a31f34',
display: 'standalone',
icon: 'src/images/MIT-logo.svg', // MIT logos: http://web.mit.edu/graphicidentity/download-logos.html
},
},
{
resolve: 'gatsby-plugin-offline',
options: {
precachePages: ['/courseware/'],
},
},
/*
Install gatsby-source-datocms and uncomment here to use DatoCMS with Gatsby.
We only use Apollo Client GraphQL queries for the time being.
{
resolve: 'gatsby-source-datocms',
options: datocmsOptions,
},
*/
{
resolve: 'gatsby-plugin-eslint',
options: {
test: /\.js$|\.jsx$/,
exclude: /(node_modules|.cache|public)/,
stages: ['develop'],
options: {
emitWarning: true,
failOnError: false,
},
},
},
{
resolve: 'gatsby-plugin-stylelint',
options: { files: ['**/*.scss'] },
},
{
resolve: 'gatsby-plugin-create-client-paths',
options: { prefixes: ['/courseware/*', '/account/*'] },
},
{
resolve: 'gatsby-plugin-google-analytics',
options: gaOptions,
},
{
resolve: 'gatsby-plugin-heap',
options: haOptions,
},
],
};