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
| // nuxt.config.ts
export default defineNuxtConfig({
// 开发环境
devtools: { enabled: true },
// 模块
modules: [
'@pinia/nuxt',
'@nuxtjs/color-mode',
'@vueuse/nuxt',
'nuxt-icon',
],
// CSS
css: ['~/assets/css/main.css'],
// PostCSS
postcss: {
plugins: {
tailwindcss: {},
autoprefixer: {},
},
},
// 应用配置
app: {
head: {
title: 'Vue3 内容平台',
meta: [
{ charset: 'utf-8' },
{ name: 'viewport', content: 'width=device-width, initial-scale=1' },
{ name: 'description', content: '分享技术与生活' },
],
link: [
{ rel: 'icon', type: 'image/svg+xml', href: '/favicon.svg' },
],
},
pageTransition: { name: 'page', mode: 'out-in' },
},
// 运行时配置
runtimeConfig: {
// 服务端私密配置
databaseUrl: process.env.DATABASE_URL,
jwtSecret: process.env.JWT_SECRET,
// 客户端公开配置
public: {
apiBase: '/api',
siteName: 'Vue3 内容平台',
},
},
// 路由规则(混合渲染)
routeRules: {
// 首页 SSR
'/': { ssr: true },
// 文章列表 SSR
'/articles': { ssr: true },
// 文章详情页 SSR
'/articles/**': { ssr: true },
// 用户页面 SSR
'/user/**': { ssr: true },
// 管理后台 CSR(客户端渲染)
'/admin/**': { ssr: false },
// 搜索页 SSR
'/search': { ssr: true },
// API 路由
'/api/**': { cors: true },
},
// Nitro 配置
nitro: {
prerender: {
// 预渲染静态页面
routes: ['/', '/articles', '/categories'],
},
compressPublicAssets: true,
},
// Vite 配置
vite: {
css: {
preprocessorOptions: {
scss: {
additionalData: '@use "~/assets/scss/variables.scss" as *;',
},
},
},
},
// TypeScript
typescript: {
strict: true,
typeCheck: true,
},
// 实验性功能
experimental: {
payloadExtraction: true, // 优化客户端水合
renderJsonPayloads: true,
},
})
|