-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathnuxt.config.js
234 lines (214 loc) · 6.84 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
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
const pkg = require('./package')
const axios = require('axios')
require('dotenv').config()
module.exports = {
/*
** Headers of the page
*/
head: {
htmlAttrs: {
lang: 'de-AT',
},
title: pkg.name,
//titleTemplate: '%s - ' + pkg.name,
meta: [
{ charset: 'utf-8' },
{ name: 'viewport', content: 'width=device-width, initial-scale=1' },
{ name: 'msapplication-TileColor', content: '#241E15' },
{ name: 'msapplication-TileImage', content: '/favicon/ms-icon-144x144.png' },
{ name: 'theme-color', content: '#241E15' },
{ hid: 'description', name: 'description', content: pkg.description },
{ hid: 'og:type', propery: 'og:type', content: 'website' },
{ hid: 'og:title', propery: 'og:title', content: pkg.name },
{ hid: 'og:description', propery: 'og:description', content: pkg.description },
{ hid: 'og:image', propery: 'og:image', content: 'https://img2.storyblok.com/1200x630/f/54536/2048x1365/5ca76528f1/solmates.jpg' },
{ hid: 'og:site_name', propery: 'og:site_name', content: pkg.name },
{ hid: 'og:url', property: 'og:url', content: 'https://www.solmates.at' },
{ hid: 'twitter:card', name: 'twitter:card', content: 'summary' },
{ hid: 'twitter:site', name: 'twitter:site', content: '@solmates' }, // TODO: add Twitter Account @solmates
{ hid: 'twitter:title', name: 'twitter:title', content: pkg.name },
{ hid: 'twitter:description', name: 'twitter:description', content: pkg.description },
{ hid: 'twitter:image', name: 'twitter:image', content: 'https://img2.storyblok.com/1200x630/f/54536/2048x1365/5ca76528f1/solmates.jpg' }
],
link: [
{ rel: 'preconnect', href: '//www.googletagmanager.com' },
{ rel: 'preconnect', href: '//www.google-analytics.com' },
{ rel: 'preconnect', href: '//fonts.googleapis.com' }
]
},
/*
** Customize the progress-bar color
*/
loading: { color: '#087E8B' },
/*
** Global CSS
*/
/*css: [
'~/assets/scss/styles.scss'
],*/
/*
** Plugins to load before mounting the App
*/
plugins: [
'@/plugins/components',
'@/plugins/filters',
'@/plugins/helper',
'@/plugins/vue-lazysizes.client.js',
'@/plugins/vue-js-modal.js'
],
/*
** Nuxt.js modules
*/
modules: [
['storyblok-nuxt', {accessToken: process.env.STORYBLOK_API_TOKEN, cacheProvider: 'memory', excludeHeaderScript: false}],
'@nuxtjs/style-resources',
['vue-scrollto/nuxt', { duration: 300, offset: -70 }],
'@bazzite/nuxt-optimized-images',
'nuxt-webfontloader',
'@nuxtjs/pwa',
'@nuxtjs/sitemap',
'@nuxtjs/dotenv',
'@nuxtjs/gtm',
],
gtm: {
id: process.env.GTM_ID,
pageTracking: true,
},
styleResources: {
scss: [
'./assets/scss/_variables.scss',
'./assets/scss/_mixins.scss'
]
},
optimizedImages: {
inlineImageLimit: -1,
handleImages: ['jpeg', 'png', 'svg', 'webp', 'gif'],
optimizeImages: true,
optimizeImagesInDev: false,
defaultImageLoader: 'img-loader',
mozjpeg: {
quality: 85
},
optipng: false,
pngquant: {
speed: 7,
quality: [0.65, 0.8]
},
webp: {
quality: 85
}
},
webfontloader: {
custom: {
families: [
'Crimson Text:n4,i4,n6',
'Work Sans:n4,n5,n6'
],
urls: [
'https://fonts.googleapis.com/css?family=Crimson+Text:400,400i,600&display=swap',
'https://fonts.googleapis.com/css?family=Work+Sans:400,500,600&display=swap'
]
}
},
pwa: {
manifest: {
name: 'Solmates',
short_name: 'Solmates',
lang: 'de-AT',
start_url: 'https://www.solmates.at/',
theme_color: '#241E15',
background_color: "#F5F1EB",
display: "standalone",
orientation: "portrait-primary"
},
workbox: {
runtimeCaching: [
{
urlPattern: 'https://fonts.googleapis.com/.*',
handler: 'cacheFirst',
method: 'GET',
strategyOptions: {cacheableResponse: {statuses: [0, 200]}}
},
{
urlPattern: 'https://fonts.gstatic.com/.*',
handler: 'cacheFirst',
method: 'GET',
strategyOptions: {cacheableResponse: {statuses: [0, 200]}}
},
]
}
},
sitemap: {
hostname: 'https://www.solmates.at',
gzip: true,
exclude: [
'/404',
'/kontakt/erfolg'
]
},
/*
** Build configuration
*/
build: {
/*
** You can extend webpack config here
** https://dev.to/ignore_you/minify-generate-webp-and-lazyload-images-in-your-vue-nuxt-application-1ilm
*/
extend (config, { isDev, isClient, loaders: { vue } }) {
if (isClient) {
vue.transformAssetUrls.img = ['data-src', 'src']
vue.transformAssetUrls.source = ['data-srcset', 'srcset']
}
},
/*
** Prevents multiple styles (https://github.com/nuxt/nuxt.js/issues/3877)
*/
splitChunks: {
layouts: true
},
analyze: true
},
/*
** Generate Routes via Storybloks Links API.
*/
generate: {
routes: function (callback) {
const token = process.env.STORYBLOK_API_TOKEN
const per_page = 100
const version = `draft`
let page = 1
let routes = []
// Call first Page of the Links API: https://www.storyblok.com/docs/Delivery-Api/Links
axios.get(`https://api.storyblok.com/v1/cdn/links?token=${token}&version=${version}&per_page=${per_page}&page=${page}`).then((res) => {
Object.keys(res.data.links).forEach((key) => {
if (res.data.links[key].slug != 'home' && res.data.links[key].slug != 'settings') {
routes.push('/' + res.data.links[key].slug)
}
})
// Check if there are more pages available otherwise execute callback with current routes.
const total = res.headers.total
const maxPage = Math.ceil(total / per_page)
if(maxPage <= 1) {
callback(null, routes)
}
// Since we know the total we now can pregenerate all requests we need to get all Links
let contentRequests = []
for (let page = 2; page <= maxPage; page++) {
contentRequests.push(axios.get(`https://api.storyblok.com/v1/cdn/links?token=${token}&version=${version}&per_page=${per_page}&page=${page}`))
}
// Axios allows us to exectue all requests using axios.spread we will than generate our routes and execute the callback
axios.all(contentRequests).then(axios.spread((...requests) => {
requests.forEach((request) => {
Object.keys(request.data.links).forEach((key) => {
if (request.data.links[key].slug != 'home') {
routes.push('/' + request.data.links[key].slug)
}
})
})
callback(null, routes)
})).catch(callback)
})
},
fallback: true
}
}