-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathnuxt.config.ts
More file actions
236 lines (216 loc) · 5.84 KB
/
nuxt.config.ts
File metadata and controls
236 lines (216 loc) · 5.84 KB
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
// @ts-ignore
import tailwindcss from "@tailwindcss/vite";
const sensitiveRouteHeaders = {
'cache-control': 'private, no-store, max-age=0, must-revalidate',
'pragma': 'no-cache',
'surrogate-control': 'no-store',
'vary': 'cookie, authorization'
} as const
const sensitiveRouteRule = {
cache: false,
prerender: false,
headers: sensitiveRouteHeaders
} as const
export default defineNuxtConfig({
compatibilityDate: '2024-11-01',
srcDir: 'app',
dir: {
app: 'app',
},
css: ['~/assets/css/main.css'],
// Enable SSR and prerendering for better performance
ssr: true,
nitro: {
prerender: {
routes: ['/sitemap.xml', '/robots.txt']
}
},
sitemap: {
exclude: ['/internal/**', '/confirm', '/login'],
},
// Performance optimizations
experimental: {
payloadExtraction: false // Reduce JS payload size
},
app: {
head: {
viewport: 'width=device-width, initial-scale=1, viewport-fit=cover',
},
},
// Enhanced caching and performance headers
routeRules: {
// Homepage pre-rendered at build time
'/': { isr: 300, headers: { 'cache-control': 's-maxage=60' } },
// Articles page cached for 10 minutes with ISR
'/articles': { isr: 600, headers: { 'cache-control': 's-maxage=300' } },
// Individual articles cached for 1 hour
'/articles/**': { isr: 3600, headers: { 'cache-control': 's-maxage=1800' } },
// Radar page short-term cache (5 minutes)
'/radar': { isr: 300, headers: { 'cache-control': 's-maxage=150' } },
// Search page client-side only
'/search': { prerender: false },
// Admin pages rendered fully on the client to avoid shared caching
'/internal/**': sensitiveRouteRule,
'/login': sensitiveRouteRule,
// API routes with appropriate caching
'/api/**': { cors: true, headers: { 'cache-control': 's-maxage=60' } },
// Specific nuxt icon API route
'/api/_nuxt_icon/**': { cors: true, headers: { 'cache-control': 's-maxage=31536000' } }
},
modules: [
'@nuxt/fonts',
'@nuxt/icon',
'@nuxt/image',
'@nuxt/ui',
'@nuxt/scripts',
'@nuxtjs/supabase',
'nuxt-swiper',
'@vite-pwa/nuxt',
'@nuxtjs/seo',
'@nuxtjs/robots',
'@nuxtjs/sitemap',
'nuxt-schema-org',
'nuxt-umami'
],
supabase: {
redirectOptions: {
include: ["/internal"],
login: '/login',
callback: '/login',
},
},
vite: {
plugins: [
tailwindcss(),
],
},
typescript: {
typeCheck: true,
tsConfig: {
compilerOptions: {
noUncheckedIndexedAccess: false,
},
},
},
ui: {
colorMode: false,
},
icon: {
clientBundle: {
scan: true,
}
},
seo: {
fallbackTitle: false,
redirectToCanonicalSiteUrl: true,
},
site: {
url: process.env.NUXT_PUBLIC_SITE_URL || 'https://sursaut-revue.fr',
name: 'Revue Sursaut!',
description: 'Le journal des luttes de Bordeaux, un espace pour partager et documenter les luttes sociales et politiques.',
defaultLocale: 'fr',
},
umami: {
id: "779e00d4-6269-4d73-8c5b-950948c25b18",
host: "https://stats.sursaut-revue.fr",
autoTrack: true,
},
pwa: {
registerType: 'autoUpdate',
workbox: {
globPatterns: ['**/*.{js,css,html,png,svg,ico}'],
cleanupOutdatedCaches: true,
navigateFallbackDenylist: [/^\/login/, /^\/api/, /^\/internal/],
runtimeCaching: [
{
urlPattern: /^https:\/\/fonts\.googleapis\.com\/.*/i,
handler: 'CacheFirst',
options: {
cacheName: 'google-fonts-cache',
expiration: {
maxEntries: 10,
maxAgeSeconds: 60 * 60 * 24 * 365 // 1 year
}
}
},
{
urlPattern: /^https:\/\/.*\.supabase\.co\/rest\/v1\/(articles|categories|issues|laveille)(\?.*)?$/i,
handler: 'StaleWhileRevalidate',
options: {
cacheName: 'supabase-content-cache',
expiration: {
maxEntries: 100,
maxAgeSeconds: 60 * 5 // 5 minutes for content
},
plugins: [{
cacheWillUpdate: async ({ response }: { response: Response }) => {
return response.status === 200 ? response : null
}
}]
}
},
{
urlPattern: /^https:\/\/.*\.supabase\.co\/storage\/v1\/object\/public\/.*/i,
handler: 'CacheFirst',
options: {
cacheName: 'supabase-images-cache',
expiration: {
maxEntries: 200,
maxAgeSeconds: 60 * 60 * 24 * 7 // 1 week for images
}
}
}
]
},
manifest: {
name: 'Revue Sursaut!',
short_name: 'Sursaut!',
description: 'Le journal des luttes de Bordeaux, un espace pour partager et documenter les luttes sociales et politiques.',
theme_color: '#FCFAF8', // amber-50
background_color: '#FCFAF8', // amber-50
display: 'standalone',
start_url: '/',
scope: '/',
orientation: 'portrait-primary',
icons: [
{
src: '/icon-192x192.png',
sizes: '192x192',
type: 'image/png',
},
{
src: '/icon-512x512.png',
sizes: '512x512',
type: 'image/png',
},
{
src: '/icon-512x512.png',
sizes: '512x512',
type: 'image/png',
purpose: 'any maskable',
},
{
src: '/apple-touch-icon.png',
sizes: '180x180',
type: 'image/png',
},
],
share_target: {
action: '/radar',
method: 'GET',
enctype: 'application/x-www-form-urlencoded',
params: {
text: 'url',
}
}
},
devOptions: {
enabled: true,
type: 'module',
navigateFallbackAllowlist: [/^\/$/]
},
},
devtools: {
enabled: true
}
})