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
| import { defineConfig } from 'vite'
| import vue from '@vitejs/plugin-vue'
| import { resolve } from 'path'
|
| export default defineConfig({
| plugins: [vue()],
| resolve: {
| alias: {
| '@': resolve(__dirname, 'src')
| }
| },
| server: {
| host: '0.0.0.0',
| port: 3000,
| open: true,
| proxy: {
| '/api': {
| target: 'http://127.0.0.1:8080',
| changeOrigin: true,
| secure: false,
| configure: (proxy, options) => {
| proxy.on('error', (err, req, res) => {
| console.log('proxy error', err);
| });
| proxy.on('proxyReq', (proxyReq, req, res) => {
| console.log('Sending Request to the Target:', req.method, req.url);
| });
| proxy.on('proxyRes', (proxyRes, req, res) => {
| console.log('Received Response from the Target:', proxyRes.statusCode, req.url);
| });
| },
| // 不需要重写路径,因为后端的context-path就是/api
| // rewrite: (path) => path.replace(/^\/api/, '/api')
| }
| }
| },
| build: {
| outDir: 'dist',
| assetsDir: 'assets',
| sourcemap: false,
| minify: 'terser',
| terserOptions: {
| compress: {
| drop_console: true,
| drop_debugger: true
| }
| }
| }
| })
|
|