-
Notifications
You must be signed in to change notification settings - Fork 16
Expand file tree
/
Copy pathnuxt.config.ts
More file actions
119 lines (114 loc) · 3.06 KB
/
Copy pathnuxt.config.ts
File metadata and controls
119 lines (114 loc) · 3.06 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
// https://nuxt.com/docs/api/configuration/nuxt-config
import copyKatexFonts from './utils/copy-katex-font'
import mirrorPublicAssets from './utils/mirror-public-assets'
import replace from '@rollup/plugin-replace'
import { execSync } from 'child_process'
import { resolve } from 'path'
let nitroOutputDirs: { publicDir?: string, serverDir?: string } = {}
export default defineNuxtConfig({
modules: [
'@nuxt/eslint',
'@nuxt/ui',
'@nuxtjs/i18n',
'@vite-pwa/nuxt'
],
ssr: true,
components: true,
devtools: {
enabled: true
},
css: ['~/assets/css/main.css', '~/assets/scss/katex.scss'],
vue: {
compilerOptions: {
isCustomElement: tag => tag === 'math-field'
}
},
compatibilityDate: '2025-01-15',
vite: {
plugins: [
replace({
preventAssignment: true,
values: {
__COMMIT__: execSync('git rev-parse HEAD').toString().trim(),
__BUILD_DATE__: new Date().toLocaleString()
}
})
]
},
hooks: {
'ready': (nuxt) => {
copyKatexFonts(nuxt.options.rootDir)
},
'nitro:build:public-assets': (nitro) => {
const publicDir = nitro?.options?.output?.publicDir
const serverDir = nitro?.options?.output?.serverDir
nitroOutputDirs = { publicDir, serverDir }
if (publicDir && serverDir) {
mirrorPublicAssets(publicDir, resolve(serverDir))
}
},
'build:done': () => {
if (nitroOutputDirs.publicDir && nitroOutputDirs.serverDir) {
mirrorPublicAssets(nitroOutputDirs.publicDir, resolve(nitroOutputDirs.serverDir))
return
}
const outputDir = resolve(process.cwd(), '.output')
mirrorPublicAssets(resolve(outputDir, 'public'), resolve(outputDir, 'server'))
}
},
eslint: {
config: {
stylistic: {
commaDangle: 'never',
braceStyle: '1tbs'
}
}
},
i18n: {
locales: [
{ code: 'zh-CN', name: '中文', file: 'zh-CN.json' },
{ code: 'en', name: 'English', file: 'en.json' }
],
defaultLocale: 'en',
langDir: 'locales',
strategy: 'no_prefix'
},
pwa: {
registerType: 'autoUpdate',
manifest: {
name: 'Texo In-browser LaTeX OCR',
short_name: 'Texo',
description: 'In-browser LaTeX formula OCR tool',
theme_color: '#10B981',
background_color: '#ffffff',
display: 'standalone',
scope: '/',
start_url: '/',
icons: [
{
src: '/icon-192x192.png',
sizes: '192x192',
type: 'image/png'
},
{
src: '/icon-512x512.png',
sizes: '512x512',
type: 'image/png'
}
]
},
workbox: {
globPatterns: ['**/*.{js,json,css,html,txt,svg,png,ico,webp,woff,woff2,ttf,eot,otf,wasm}'],
maximumFileSizeToCacheInBytes: 25 * 1024 * 1024 // 25MB
// 不添加 runtimeCaching,让 @huggingface/transformers 自己管理模型缓存
},
client: {
installPrompt: true,
periodicSyncForUpdates: 60 * 60 * 24 // per day
},
devOptions: {
enabled: true,
type: 'module'
}
}
})