generated from vtex-sites/base.store
-
Notifications
You must be signed in to change notification settings - Fork 0
/
gatsby-config.js
203 lines (196 loc) · 4.73 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
require('dotenv').config({ path: 'vtex.env' })
const { join, resolve } = require('path')
const { getSchema, getContextFactory } = require('./src/server')
const images = require('./src/images/config')
const config = require('./store.config')
const {
NODE_ENV,
URL = config.storeUrl,
DEPLOY_PRIME_URL = URL,
CONTEXT: ENV = NODE_ENV,
VTEX_WEBOPS: isWebOps,
} = process.env
const isProduction = ENV === 'production'
const siteUrl = isProduction ? URL : DEPLOY_PRIME_URL
const unique = (x) => Array.from(new Set(x))
const getSizes = (variants) =>
unique(
Object.values(variants)
.flatMap((variant) =>
variant.breakpoints.map((width) => [
`${width}x${Math.ceil(width / variant.aspectRatio)}`,
`${width}x${Math.floor(width / variant.aspectRatio)}`,
])
)
.flat()
)
module.exports = {
siteMetadata: {
title: 'Fashion Store',
description: 'Fashion Demo Store',
titleTemplate: '%s | Fashion Store',
author: 'Store Framework',
siteUrl,
},
flags: {
DEV_SSR: true,
FAST_DEV: true,
LMDB_STORE: false,
PARALLEL_SOURCING: true,
PARALLEL_QUERY_RUNNING: false,
PRESERVE_FILE_DOWNLOAD_CACHE: false,
},
plugins: [
{
resolve: 'gatsby-plugin-manifest',
options: {
name: 'Fashion Demo Store',
short_name: 'Fashion Store',
start_url: '/',
icon: 'src/images/icon.png',
background_color: '#E31C58',
theme_color: '#E31C58',
display: 'standalone',
cache_busting_mode: 'none',
},
},
{
resolve: 'gatsby-plugin-offline',
options: {
precachePages: [`/offline`],
appendScript: 'src/custom-sw-code.js',
workboxConfig: {
globPatterns: ['**/offline/*'],
},
},
},
{
resolve: 'gatsby-plugin-robots-txt',
options: {
resolveEnv: () => ENV,
env: {
production: {
policy: [
{
userAgent: '*',
allow: '/',
disallow: ['/checkout/*'],
},
],
},
'branch-deploy': {
policy: [{ userAgent: '*', disallow: ['/'] }],
},
'deploy-preview': {
policy: [{ userAgent: '*', disallow: ['/'] }],
},
},
},
},
{
resolve: 'gatsby-plugin-next-seo',
options: {
defer: true,
},
},
{
resolve: 'gatsby-plugin-image',
},
{
resolve: '@vtex/gatsby-plugin-thumbor',
options: {
server: 'https://thumbor-dev-server.vtex.io',
...(isWebOps && {
server: 'http://thumbor.vtex.internal',
basePath: '/assets',
sizes: getSizes(images),
}),
},
},
{
resolve: 'gatsby-plugin-nprogress',
options: {
color: '#E31C58',
showSpinner: false,
},
},
{
resolve: 'gatsby-plugin-root-import',
options: {
src: resolve('./src'),
'@generated': resolve('./@generated'),
},
},
{
resolve: 'gatsby-plugin-bundle-stats',
options: {
compare: true,
baseline: true,
html: true,
json: true,
outDir: `.`,
stats: {
context: join(__dirname, 'src'),
},
},
},
{
resolve: `@vtex/gatsby-source-store`,
options: {
sourceProducts: true,
sourceCollections: true,
getSchema,
getContextFactory,
// Source less products is development for better DX
maxNumProducts: isProduction ? 2500 : 100,
maxNumCollections: isProduction ? 2500 : 100,
},
},
{
resolve: '@vtex/gatsby-plugin-nginx',
options: {
httpOptions: [
['merge_slashes', 'off'],
['proxy_http_version', '1.1'],
['absolute_redirect', 'off'],
],
serverOptions: isWebOps
? [['resolver', '169.254.169.253']]
: [['resolver', '8.8.8.8']],
locations: {
append: {
cmd: ['location', '/'],
children: [
{
cmd: [
'add_header',
'Cache-Control',
'"public, max-age=0, must-revalidate"',
],
},
{
cmd: [
'try_files',
'$uri',
'$uri/',
'$uri/index.html',
'$uri.html',
'=404',
],
},
],
},
},
},
},
{
resolve: 'gatsby-plugin-gatsby-cloud',
},
{
resolve: 'gatsby-plugin-netlify',
},
{
resolve: 'gatsby-plugin-postcss',
},
],
}