forked from binary-com/deriv-com
-
Notifications
You must be signed in to change notification settings - Fork 0
/
gatsby-config.js
336 lines (329 loc) · 11.9 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
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
const language_config = require(`./i18n-config.js`)
require('dotenv').config({
path: `.env.${process.env.NODE_ENV}`,
})
const site_url = 'https://deriv.com'
module.exports = {
// pathPrefix: process.env.PATH_PREFIX || '/deriv-com/', // For non CNAME GH-pages deployment
flags: {
FAST_DEV: true,
DEV_SSR: false,
},
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: site_url,
},
partytownProxiedURLs: [
`https://assets.customer.io/assets/track-eu.js`,
`https://assets.customer.io/assets/track.js`,
`https://static.deriv.com/scripts/cookie.js`,
`https://widget.trustpilot.com/bootstrap/v5/tp.widget.bootstrap.min.js`,
],
plugins: [
'gatsby-plugin-react-helmet',
{
resolve: `gatsby-plugin-react-helmet-canonical-urls`,
options: {
siteUrl: `${site_url}`,
noQueryString: true,
},
},
'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,
stripMetadata: true,
defaultQuality: 50,
},
},
`gatsby-plugin-image`,
{
resolve: 'gatsby-plugin-sitemap',
options: {
excludes: [
'/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',
'/academy/blog/posts/preview',
'/academy/subscription',
],
query: `
{
allSitePage {
nodes {
path
}
}
}
`,
resolveSiteUrl: () => site_url,
resolvePages: ({ allSitePage: { nodes: allPages } }) => {
return allPages.map((page) => {
return { ...page }
})
},
serialize: ({ path }) => {
const ignore_localized_regex = /careers|besquare|livechat|academy/
const languages = Object.keys(language_config)
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 = ['en', 'x-default'].includes(locale)
const href_locale = is_default ? '' : `/${replaced_locale}`
const href = `${site_url}${href_locale}${current_page}`
return { lang: replaced_locale, url: href }
}
})
return {
url: path,
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: '#000000',
theme_color: '#000000',
display: 'standalone',
icon: './favicons/favicon-512x512.png',
icons: [
{
src: `favicons/favicon-48x48.png`,
sizes: `48x48`,
type: `image/png`,
purpose: 'any maskable',
},
{
src: `favicons/favicon-72x72.png`,
sizes: `72x72`,
type: `image/png`,
purpose: 'any maskable',
},
{
src: `favicons/favicon-96x96.png`,
sizes: `96x96`,
type: `image/png`,
purpose: 'any maskable',
},
{
src: `favicons/favicon-144x144.png`,
sizes: `144x144`,
type: `image/png`,
purpose: 'any maskable',
},
{
src: `favicons/favicon-192x192.png`,
sizes: `192x192`,
type: `image/png`,
purpose: 'any maskable',
},
{
src: `favicons/favicon-256x256.png`,
sizes: `256x256`,
type: `image/png`,
purpose: 'any maskable',
},
{
src: `favicons/favicon-384x384.png`,
sizes: `384x384`,
type: `image/png`,
purpose: 'any maskable',
},
{
src: `favicons/favicon-512x512.png`,
sizes: `512x512`,
type: `image/png`,
},
{
src: `icons/icon-48x48.png`,
sizes: `48x48`,
type: `image/png`,
purpose: 'any maskable',
},
{
src: `icons/icon-72x72.png`,
sizes: `72x72`,
type: `image/png`,
purpose: 'any maskable',
},
{
src: `icons/icon-96x96.png`,
sizes: `96x96`,
type: `image/png`,
purpose: 'any maskable',
},
{
src: `icons/icon-144x144.png`,
sizes: `144x144`,
type: `image/png`,
purpose: 'any maskable',
},
{
src: `icons/icon-192x192.png`,
sizes: `192x192`,
type: `image/png`,
purpose: 'any maskable',
},
{
src: `icons/icon-256x256.png`,
sizes: `256x256`,
type: `image/png`,
purpose: 'any maskable',
},
{
src: `icons/icon-384x384.png`,
sizes: `384x384`,
type: `image/png`,
purpose: 'any maskable',
},
{
src: `icons/icon-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-google-tagmanager',
options: {
id: 'GTM-NF7884S',
includeInDevelopment: false,
},
},
{
resolve: 'gatsby-plugin-anchor-links',
options: {
offset: -100,
},
},
{
resolve: '@directus/gatsby-source-directus',
options: {
url: 'https://deriv-academy.directus.app',
auth: {
token: process.env.DIRECTUS_AUTH_TOKEN,
},
dev: {
refresh: '5s',
},
},
},
'gatsby-plugin-use-query-params',
{
resolve: 'gatsby-plugin-webpack-bundle-analyser-v2',
options: {
analyzerMode: 'disabled',
generateStatsFile: process.env.GENERATE_JSON_STATS === 'true' ? true : false,
},
},
],
}