-
Notifications
You must be signed in to change notification settings - Fork 0
/
nuxt.config.js
178 lines (173 loc) · 4.28 KB
/
nuxt.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
import fetch from 'node-fetch';
import dotenv from 'dotenv';
/**
* Import the locale files.
*/
import enGB from './locales/en-GB';
import frFR from './locales/fr-FR';
/**
* Config dotenv.
*/
dotenv.config();
/**
* Instance globals.
*/
const storeUrl = `https://${process.env.SHOPIFY_STORE}`;
const storeAccess = process.env.SHOPIFY_ACCESS;
const oneSignalId = process.env.ONESIGNAL_ID;
/**
* Nuxt.js configuration.
*/
export default {
head: {
title: 'Allbirds',
meta: [
{ name: 'description', content: 'The world’s most comfortable shoes made from premium natural materials go perfectly with your everyday escapades.' },
{ name: 'apple-mobile-web-app-status-bar-style', content: 'black-translucent' },
],
link: [
{ rel: 'preconnect', href: storeUrl },
{ rel: 'icon', type: 'image/png', href: '/favicon.png' },
],
},
styleResources: {
scss: [
'@/assets/styles/config/grid.scss',
'@/assets/styles/config/mixins.scss',
'@/assets/styles/config/fonts.scss',
'@/assets/styles/config/colors.scss',
'@/assets/styles/config/typography.scss',
'@/assets/styles/helpers/animations.scss',
],
},
loading: '~/components/LoadingScreen.vue',
modules: [
'@nuxtjs/apollo',
'@nuxtjs/onesignal',
'@nuxtjs/pwa',
'@nuxtjs/style-resources',
'cookie-universal-nuxt',
[
'nuxt-i18n',
{
locales: ['en-GB', 'fr'],
defaultLocale: 'en-GB',
vueI18n: {
fallbackLocale: 'en-GB',
messages: {
"en-GB": enGB,
fr: frFR,
},
},
vuex: {
syncLocale: true,
},
},
],
],
plugins: [
{ src: '~/plugins/vuex-persistedstate.js', ssr: false },
{ src: '~/plugins/get-locale-path.js' },
{ src: '~/plugins/vue-lazyload.js' },
],
oneSignal: {
init: {
appId: oneSignalId,
allowLocalhostAsSecureOrigin: true,
},
},
pwa: {
meta: {
name: 'Allbirds',
description: 'The world’s most comfortable shoes made from premium natural materials go perfectly with your everyday escapades.',
},
manifest: {
name: 'Allbirds',
short_name: 'Allbirds',
background_color: 'rgb(255, 255, 255)',
theme_color: 'rgb(255, 255, 255)',
icons: [
{
src: '~/static/icon.png',
type: 'image/png',
},
],
},
},
apollo: {
clientConfigs: {
default: {
httpEndpoint: `${storeUrl}/api/2019-10/graphql.json`,
httpLinkOptions: {
headers: {
'X-Shopify-Storefront-Access-Token': storeAccess,
},
},
},
},
},
router: {
extendRoutes(routes, resolve) {
routes.push(
{
name: 'login',
path: '/account/login',
component: resolve(__dirname, 'pages/account/access.vue')
},
{
name: 'register',
path: '/account/register',
component: resolve(__dirname, 'pages/account/access.vue')
},
);
},
},
generate: {
dir: 'dist',
fallback: true,
minify: {
collapseWhitespace: false,
},
routes() {
return fetch(`${storeUrl}/api/graphql`, {
method: 'POST',
headers: {
'Content-Type': 'application/graphql',
'X-Shopify-Storefront-Access-Token': storeAccess,
},
body: `
query allProducts {
products(first: 100) {
edges {
node {
handle
}
}
}
collections(first: 100) {
edges {
node {
handle
}
}
}
}
`,
})
.then((response) => response.json())
.then((response) => {
const products = response.data.products.edges.map((item) => `/products/${item.node.handle}`);
const collections = response.data.collections.edges.map((item) => `/collections/${item.node.handle}`);
return [].concat.apply([], [products, collections]);
})
.catch((error) => error);
},
},
render: {
bundleRenderer: {
shouldPreload: (type) => {
return ['script', 'style', 'font'].includes(type);
},
},
},
}