forked from ThatGuySam/doesitarm
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathnuxt.config.js
308 lines (251 loc) · 7.8 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
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
import { promises as fs } from 'fs'
// import path from 'path'
import pkg from './package'
import buildAppList from './helpers/build-app-list.js'
import buildGamesList from './helpers/build-game-list.js'
import buildHomebrewList from './helpers/build-homebrew-list.js'
import buildVideoList from './helpers/build-video-list.js'
import { categories } from './helpers/categories.js'
import { getAppEndpoint, getVideoEndpoint } from './helpers/app-derived.js'
const listsOptions = [
{
buildMethod: buildAppList,
path: '/static/app-list.json',
},
{
buildMethod: buildGamesList,
path: '/static/game-list.json',
},
{
buildMethod: buildHomebrewList,
path: '/static/homebrew-list.json',
}
]
const videoListOptions = {
buildMethod: buildVideoList,
path: '/static/video-list.json',
}
const saveList = async function ( list, buildArgs = null ) {
const methodName = `Building ${list.path}`
console.time(methodName)
// Run the build method
const builtList = await list.buildMethod(buildArgs)
// Make the relative path for our new JSON file
const listFullPath = `.${list.path}`
// console.log('listFullPath', listFullPath)
// Write the list to JSON
await fs.writeFile(listFullPath, JSON.stringify(builtList))
// Read back the JSON we just wrote to ensure it exists
const savedListJSON = await fs.readFile(listFullPath, 'utf-8')
// console.log('savedListJSON', savedListJSON)
const savedList = JSON.parse(savedListJSON)
console.timeEnd(methodName)
// Import the created JSON File
return savedList
}
const storeAppLists = async function (builder) {
console.log('Build Lists started')
const savedLists = await Promise.all(listsOptions.map(saveList))
// Build and save list of videos based on app lists
.then(async lists => {
const [
appList,
gameList
] = lists
// Build a video app list with apps and games only
const videoAppList = [
...appList,
...gameList
].flat(1)
return await saveList(videoListOptions, videoAppList)
})
console.log('Build Lists finished')
return savedLists
}
export default {
target: 'static',
publicRuntimeConfig: {
allUpdateSubscribe: process.env.ALL_UPDATE_SUBSCRIBE
},
/*
** Hooks
* https://nuxtjs.org/api/configuration-hooks/
*/
hooks: {
build: {
before: storeAppLists
},
generate: {
before: storeAppLists
}
},
generate: {
cache: {
ignore: [
// When something changed in the docs folder, do not re-build via webpack
'assets'
]
},
routes() {
return Promise.all([
...listsOptions,
videoListOptions
].map(async list => {
// Read saved lists
const methodName = `Reading ${list.path}`
console.time(methodName)
const listPath = `.${list.path}`
// Read JSON to ensure it exists
const savedListJSON = await fs.readFile(listPath, 'utf-8')
// Parse the saved JSON into a variable
const savedList = JSON.parse(savedListJSON)
console.timeEnd(methodName)
// Pass on the variable
return savedList
}))
.then(( lists ) => {
// console.log('appList', appList)
const [
appRoutes,
gameRoutes,
videoRoutes,
homebrewRoutes
] = lists.map((list, listI) => {
return list.map( app => {
const isVideo = (app.category === undefined)
if (isVideo) {
return getVideoEndpoint(app)
}
return getAppEndpoint(app)
})
})
// Build routes for app types that support benchmark endpoints
const benchmarkRoutes = [
...appRoutes,
// ...gameRoutes,
].flat(1).map( route => `${route}/benchmarks`)
// console.log('homebrewRoutes', homebrewRoutes)
const categoryRoutes = Object.keys(categories).map( slug => ({
route: '/kind/' + slug,
// payload: appList
}))
return [
...appRoutes,
...gameRoutes,
...homebrewRoutes,
// Non-app routes
...videoRoutes,
...categoryRoutes,
...benchmarkRoutes
]
})
}
},
/*
** Headers of the page
*/
head: {
// this htmlAttrs you need
htmlAttrs: {
lang: 'en',
},
title: 'Does it ARM',
meta: [
{ charset: 'utf-8' },
{
name: 'viewport',
content: 'width=device-width, initial-scale=1'
},
{
hid: 'description',
name: 'description',
content: pkg.description
},
{
'property': 'og:image',
'content': `${process.env.URL}/images/og-image.png`
},
{
'property': 'og:image:width',
'content': '1200'
},
{
'property': 'og:image:height',
'content': '627'
},
{
'property': 'og:image:alt',
'content': 'Does It ARM Logo'
},
// Twitter Card
{
'property': 'twitter:card',
'content': 'summary'
},
{
'property': 'twitter:title',
'content': 'Does It ARM'
},
{
'property': 'twitter:description',
'content': pkg.description
},
{
'property': 'twitter:url',
'content': `${process.env.URL}`
},
{
'property': 'twitter:image',
'content': `${process.env.URL}/images/mark.png`
}
],
link: [{ rel: 'icon', type: 'image/x-icon', href: '/favicon.ico' }]
},
/*
** Customize the progress-bar color
*/
loading: { color: '#fff' },
/*
** Global CSS
*/
// css: ['~/assets/css/tailwind.css'],
/*
** Plugins to load before mounting the App
*/
plugins: [],
/*
** Nuxt.js modules
*/
modules: [
'@nuxtjs/sitemap'
],
sitemap: {
hostname: 'https://doesitarm.com'
},
buildModules: [
'@nuxtjs/tailwindcss'
],
/*
** Build configuration
*/
build: {
html: { minify: { collapseWhitespace: true } },
/*
** You can extend webpack config here
*/
extend(config, ctx) {
// Run ESLint on save
if (ctx.isDev && ctx.isClient) {
config.module.rules.push({
enforce: 'pre',
test: /\.(js|vue)$/,
loader: 'eslint-loader',
exclude: /(node_modules)/
})
config.node = {
fs: "empty"
}
}
}
}
}