forked from binary-com/deriv-com
-
Notifications
You must be signed in to change notification settings - Fork 0
/
gatsby-config.js
238 lines (233 loc) · 8.57 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
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
const language_config = require(`./i18n-config.js`)
require('dotenv').config({
path: `.env.${process.env.NODE_ENV}`,
})
module.exports = {
// pathPrefix: process.env.PATH_PREFIX || '/deriv-com/', // For non CNAME GH-pages deployment
flags: {
FAST_DEV: true,
PRESERVE_WEBPACK_CACHE: true,
},
siteMetadata: {
title: 'Deriv',
description:
'Deriv.com gives everyone an easy way to participate in the financial markets. Trade with as little as $1 USD on major currencies, stocks, indices, and commodities.',
author: 'Deriv.com',
siteUrl: 'https://deriv.com',
},
plugins: [
'gatsby-plugin-react-helmet',
'gatsby-plugin-styled-components',
{
resolve: 'gatsby-source-filesystem',
options: {
name: 'images',
path: `${__dirname}/src/images/common`,
},
},
'gatsby-transformer-sharp',
{
resolve: `gatsby-plugin-sharp`,
options: {
failOnError: true,
base64Width: 20,
forceBase64Format: 'webp',
stripMetadata: true,
defaultQuality: 50,
},
},
`gatsby-plugin-image`,
{
resolve: 'gatsby-plugin-sitemap',
options: {
exclude: [
'/404',
'/**/404.html',
'/**/404',
'/check-email',
'/**/check-email',
'/reset-password',
'/**/reset-password',
'/ach',
'/ach/**',
'/amp',
'/amp/**',
'/**/amp',
'/**/amp/**',
'/interim',
'/interim/**',
'/**/interim',
'/**/interim/**',
'/homepage',
'/homepage/**',
'/**/homepage',
'/**/homepage/**',
'/offline-plugin-app-shell-fallback',
'/**/offline-plugin-app-shell-fallback',
'/landing',
'/landing/**',
'/**/landing',
'/**/landing/**',
'/endpoint',
'/**/endpoint',
'/signup-success',
'/**/signup-success',
],
serialize: ({ site, allSitePage }) =>
allSitePage.edges.map((edge) => {
const ignore_localized_regex = /careers|besquare|livechat|academy/
const path = edge.node.path
let priority = 0.7
const languages = Object.keys(language_config)
if (path === '/') {
priority = 1.0
} else if (path.match(/dbot|dtrader|dmt5|story/)) {
priority = 1.0
} else {
languages.forEach((lang) => {
if (path === `/${lang}/`) {
priority = 1.0
}
})
}
const path_array = path.split('/')
const current_lang = path_array[1]
const check_lang = current_lang.replace('-', '_')
let current_page = path
if (languages.includes(check_lang)) {
path_array.splice(1, 1)
current_page = path_array.join('/')
}
languages.push('x-default')
languages.splice(languages.indexOf('ach'), 1)
const ignore_localized = current_page.match(ignore_localized_regex)
const links = languages.map((locale) => {
if (locale !== 'ach' && locale) {
const replaced_locale = locale.replace('_', '-')
const is_default = locale === 'en' || locale === 'x-default'
const href_locale = is_default ? '' : `/${replaced_locale}`
const href = `${site.siteMetadata.siteUrl}${href_locale}${current_page}`
return { lang: replaced_locale, url: href }
}
})
return {
url: site.siteMetadata.siteUrl + edge.node.path,
changefreq: `monthly`,
priority,
links: !ignore_localized ? links : null,
}
}),
},
},
{
resolve: 'gatsby-plugin-manifest',
options: {
name: 'Deriv',
short_name: 'Deriv',
description:
'Deriv gives everyone an easy way to participate in the financial markets. Trade with as little as $1 USD on major currencies, stocks, indices, and commodities.',
start_url: '/',
background_color: '#0e0e0e',
theme_color: '#ff444f',
display: 'standalone',
icon: './favicons/favicon-512x512.png',
icons: [
{
src: `./favicons/favicon-192x192.png`,
sizes: `192x192`,
type: `image/png`,
purpose: 'any maskable',
},
{
src: `./favicons/favicon-512x512.png`,
sizes: `512x512`,
type: `image/png`,
},
],
gcm_sender_id: '370236002280',
gcm_user_visible_only: true,
crossOrigin: `use-credentials`,
// TODO: add translations and support for language routes e.g:
// localize: [
// {
// start_url: '/de/',
// lang: 'de',
// name: 'Die coole Anwendung',
// short_name: 'Coole Anwendung',
// description: 'Die Anwendung macht coole Dinge und macht Ihr Leben besser.',
// },
// ],
},
},
{
resolve: 'gatsby-plugin-svgr',
options: {
rule: {
include: /svg/, // See below to configure properly
},
},
},
{
resolve: 'gatsby-plugin-eslint',
options: {
stages: ['develop'],
extensions: ['js', 'ts', 'jsx', 'tsx'],
exclude: ['node_modules', '.cache', 'public'],
},
},
{
resolve: 'gatsby-plugin-robots-txt',
options: {
policy: [
{
userAgent: '*',
allow: '/',
disallow: [
'/404/',
'/homepage/',
'/landing/',
'/endpoint/',
'/livechat/',
'/storybook/',
],
},
],
},
},
'gatsby-plugin-anchor-links',
{
resolve: `gatsby-plugin-nprogress`,
options: {
color: `#85ACB0`,
showSpinner: false,
minimum: 0.4,
},
},
{
resolve: 'gatsby-plugin-google-tagmanager',
options: {
id: 'GTM-NF7884S',
includeInDevelopment: false,
},
},
{
resolve: 'gatsby-plugin-anchor-links',
options: {
offset: -100,
},
},
{
resolve: '@directus/gatsby-source-directus',
options: {
url: 'https://cms.deriv.cloud',
auth: {
token: process.env.DIRECTUS_AUTH_TOKEN,
},
dev: {
refresh: '5s',
},
},
},
'gatsby-plugin-use-query-params',
],
}