-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathvite.config.js
More file actions
40 lines (38 loc) · 1.01 KB
/
Copy pathvite.config.js
File metadata and controls
40 lines (38 loc) · 1.01 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
import path from 'path';
import {defineConfig, loadEnv} from 'vite';
import vue from '@vitejs/plugin-vue';
import svgLoader from 'vite-svg-loader';
import monacoEditorPlugin from 'vite-plugin-monaco-editor';
// https://vitejs.dev/config/
export default defineConfig(({mode}) => {
// 加载环境变量
const env = loadEnv(mode, process.cwd());
return {
plugins: [
vue(),
svgLoader(),
monacoEditorPlugin({
languageWorkers: ['json', 'editorWorkerService'], // 确保正确配置 languageWorkers
}),
],
server: {
host: '0.0.0.0',
port: Number(env.VITE_PORT),
open: true,
},
build: {
outDir: env.VITE_OUT_DIR || 'dist',
terserOptions: {
compress: {
drop_console: mode === 'production', // 生产环境去除 console.log
drop_debugger: mode === 'production', // 生产环境去除 debugger
},
},
},
resolve: {
alias: {
'@': path.resolve(__dirname, './src'),
},
},
};
});