-
Notifications
You must be signed in to change notification settings - Fork 13
/
nuxt.config.ts
123 lines (109 loc) · 3.2 KB
/
nuxt.config.ts
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
const generateDynamicV = () => {
const now = new Date()
const year = now.getFullYear().toString()
const month = (now.getMonth() + 1).toString().padStart(2, "0")
const day = now.getDate().toString().padStart(2, "0")
const hour = now.getHours().toString().padStart(2, "0")
const minute = now.getMinutes().toString().padStart(2, "0")
return year + month + day + hour + minute
}
const isDev = process.env.NODE_ENV === "development"
const appBase = "/"
const staticV = generateDynamicV()
// https://nuxt.com/docs/api/configuration/nuxt-config
export default defineNuxtConfig({
// https://nuxt.com/docs/guide/concepts/typescript#nuxttsconfigjson
typescript: {
strict: true,
},
devtools: {
enabled: false,
},
// build modules
modules: ["@vueuse/nuxt", "@nuxtjs/i18n", "@element-plus/nuxt", "@nuxtjs/color-mode", "@pinia/nuxt", "@nuxt/image"],
// vueuse
vueuse: {
ssrHandlers: true,
},
i18n: {
vueI18n: "./i18n.ts",
},
// colorMode
// 格式是 `class="light-${classSuffix}"`,为空是 `class="light"`
colorMode: {
classSuffix: "",
},
image: {},
vite: {
define: {
"process.env.DEV_MODE": `"${isDev}"`,
"process.env.APP_BASE": `"${appBase}"`,
"process.env.SSR": `"true"`,
},
plugins: [],
},
elementPlus: {
icon: "ElIcon",
importStyle: "scss",
themes: ["dark"],
},
css: ["~/assets/siyuan/style.styl", "~/assets/siyuan/index.styl"],
app: {
baseURL: appBase,
head: {
charset: "utf-8",
viewport: "width=device-width, initial-scale=1",
htmlAttrs: {
lang: "zh_CN",
"data-theme-mode": "system",
"data-light-theme": "Zhihu",
"data-dark-theme": "Zhihu",
},
link: [
{ rel: "stylesheet", href: appBase + "libs/fonts/webfont.css?v=" + staticV },
{
rel: "stylesheet",
href: appBase + "resources/stage/build/app/base.css?v=" + staticV,
},
{
rel: "stylesheet",
href: appBase + "libs/katex/0.16.10/katex.min.css?v=" + staticV,
crossorigin: "anonymous",
},
],
// https://nuxt.com/docs/api/configuration/nuxt-config#head
script: isDev
? [
{
src: appBase + "libs/eruda/eruda.js",
},
{
children: "eruda.init();console.log('eruda inited');",
},
{
defer: true,
src: appBase + "libs/katex/0.16.10/katex.min.js",
},
]
: [
{
defer: true,
src: appBase + "libs/katex/0.16.10/katex.min.js",
},
],
},
},
// 环境变量
runtimeConfig: {
siyuanAuthToken: process.env.NUXT_SIYUAN_AUTH_TOKEN,
siyuanCookie: process.env.NUXT_SIYUAN_COOKIE,
public: {
defaultType: process.env.NUXT_PUBLIC_DEFAULT_TYPE ?? "siyuan",
siyuanApiUrl: process.env.NUXT_PUBLIC_SIYUAN_API_URL ?? "http://127.0.0.1:6806",
waitTime: process.env.NUXT_PUBLIC_WAIT_TIME,
providerMode: process.env.NUXT_PUBLIC_PROVIDER_MODE ?? "false",
providerUrl: process.env.NUXT_PUBLIC_PROVIDER_URL ?? "http://127.0.0.1:8000",
},
},
compatibilityDate: "2024-09-02",
})