-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathvite.config.ts
More file actions
119 lines (113 loc) · 3.98 KB
/
vite.config.ts
File metadata and controls
119 lines (113 loc) · 3.98 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
/// <reference types="vitest/config" />
import {defineConfig, PluginOption} from "vite";
import vue from "@vitejs/plugin-vue";
import vueJsx from '@vitejs/plugin-vue-jsx'
import {fileURLToPath, URL} from "node:url";
import {prismjsPlugin} from "vite-plugin-prismjs"
import compressPlugin from "vite-plugin-compression"
const host = process.env.TAURI_DEV_HOST;
// https://vitejs.dev/config/
export default defineConfig(async (env) => {
const shouldCompress = env.mode === "browser";
const plugins: PluginOption[] = [
vue(),
vueJsx(),
prismjsPlugin({
languages: [
'javascript', 'js', 'jsx', 'typescript', 'ts', "tsx",
'css', 'css-extras', 'html', 'less', 'sass', 'scss',
'svg', 'icon',
'markup', "markdown", "md",
'http', 'uri', 'url',
'c', 'cpp', 'cmake', 'objc',
'rust',
'go',
'php', 'phpdoc',
'perl',
'java', 'javadoc', 'groovy', 'kotlin', 'kt', 'kts', 'scala',
'latex', 'tex', 'matlab',
'sql', 'graphql', 'mongodb',
'erlang',
'lua',
'python', 'py', 'django', 'jinja2',
'csharp', 'dotnet',
'cobol',
'makefile',
'mermaid',
'json', 'json5', 'jsonp',
'xml', 'yaml', 'yml', 'ini', 'toml',
'bash', 'shell', 'batch',
'docker', 'dockerfile',
'git',
'vim',
'dns-zone',
'log',
'qml',
'scheme',
'swift'
],
'plugins': ['inline-color'],
css: true
}),
]
if (shouldCompress) {
plugins.push(compressPlugin({
filter: /\.(js|css|json|txt|ico|svg)(\?.*)?$/i, // 需要压缩的文件
threshold: 1024, // 文件容量大于这个值进行压缩
algorithm: 'gzip', // 压缩方式
ext: 'gz', // 后缀名
deleteOriginFile: true, // 压缩后是否删除压缩源文件
}))
}
return {
plugins,
// Vite options tailored for Tauri development and only applied in `tauri dev` or `tauri build`
//
// 1. prevent vite from obscuring rust errors
clearScreen: false,
// 2. tauri expects a fixed port, fail if that port is not available
server: {
port: 1420,
strictPort: true,
host: host || false,
hmr: host
? {
protocol: "ws",
host,
port: 1421,
}
: undefined,
watch: {
// 3. tell vite to ignore watching `src-tauri`
ignored: ["**/src-tauri/**"],
},
},
resolve: {
alias: {
'@': fileURLToPath(new URL('./src', import.meta.url))
}
},
test: {
globals: false,
environment: 'jsdom',
},
build: {
rollupOptions: {
output: {
manualChunks: {
'vue': ['vue'],
'vue-flow': ['@vue-flow/core', '@vue-flow/node-toolbar'],
'lodash': ['lodash-es'],
'monaco-editor': ['monaco-editor'],
'prismjs': ['prismjs'],
'markdown-it': ['markdown-it', 'markdown-it-emoji', 'markdown-it-mark', 'markdown-it-multimd-table', 'markdown-it-sub', 'markdown-it-sup', 'markdown-it-task-lists'],
'mermaid': ['mermaid'],
'katex': ['katex'],
'image-viewer': ['v-viewer', 'viewerjs'],
'html-to-image': ['html-to-image'],
}
}
}
}
}
});