-
Notifications
You must be signed in to change notification settings - Fork 10
Expand file tree
/
Copy pathnuxt.config.ts
More file actions
82 lines (73 loc) · 2.23 KB
/
Copy pathnuxt.config.ts
File metadata and controls
82 lines (73 loc) · 2.23 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
// https://nuxt.com/docs/api/configuration/nuxt-config
import { readFileSync, existsSync } from 'fs'
// 手动加载 .env 以支持 vite 配置中的环境变量
if (existsSync('.env')) {
readFileSync('.env', 'utf-8').split('\n').forEach(line => {
const [key, ...vals] = line.split('=')
if (key && !key.startsWith('#') && !process.env[key]) {
process.env[key] = vals.join('=')
}
})
}
const hmrPort = Number(process.env.NUXT_HMR_PORT) || 24678
console.log('[nuxt.config] HMR Port:', hmrPort)
export default defineNuxtConfig({
compatibilityDate: '2024-11-01',
devtools: { enabled: true },
future: { compatibilityVersion: 4 },
modules: ['@nuxt/ui'],
css: [
'~/assets/css/main.css',
'@vue-flow/core/dist/style.css',
'@vue-flow/core/dist/theme-default.css',
'@vue-flow/minimap/dist/style.css',
'@vue-flow/controls/dist/style.css',
'@vue-flow/node-resizer/dist/style.css',
],
app: {
head: {
// 默认标题,运行时通过 useHead 动态更新
title: '网站标题 - 系统介绍副标题',
meta: [
{ name: 'description', content: '系统介绍副标题' },
],
link: [
{ rel: 'icon', type: 'image/x-icon', href: '/favicon.ico' },
{ rel: 'icon', type: 'image/png', sizes: '16x16', href: '/favicon-16x16.png' },
{ rel: 'icon', type: 'image/png', sizes: '32x32', href: '/favicon-32x32.png' },
{ rel: 'apple-touch-icon', sizes: '180x180', href: '/apple-touch-icon.png' },
],
},
},
// 默认使用 dark 模式
colorMode: {
preference: 'dark',
},
// 使用本地图标包,避免运行时网络请求
icon: {
serverBundle: 'local',
},
// 禁用 Google Fonts 避免网络问题
fonts: {
provider: 'none',
},
runtimeConfig: {
// 公开 URL(用于返回完整的资源链接)
// 运行时通过 NUXT_PUBLIC_URL 环境变量覆盖
publicUrl: '',
public: {
// 运行时通过 NUXT_PUBLIC_SITE_NAME / NUXT_PUBLIC_SITE_SLOGAN 环境变量覆盖
siteName: '网站标题',
siteSlogan: '系统介绍副标题',
},
},
// Vite 配置:HMR 端口和远程访问
vite: {
server: {
hmr: {
port: hmrPort,
host: '0.0.0.0',
},
},
},
})