|
1 | | -import {fileURLToPath, URL} from 'node:url' |
| 1 | +import { fileURLToPath, URL } from "node:url"; |
2 | 2 |
|
3 | | -import {defineConfig} from 'vite' |
4 | | -import vue from '@vitejs/plugin-vue' |
5 | | -import AutoImport from 'unplugin-auto-import/vite' |
6 | | -import Components from 'unplugin-vue-components/vite' |
7 | | -import {ElementPlusResolver} from 'unplugin-vue-components/resolvers' |
| 3 | +import { defineConfig } from "vite"; |
| 4 | +import vue from "@vitejs/plugin-vue"; |
| 5 | +import AutoImport from "unplugin-auto-import/vite"; |
| 6 | +import Components from "unplugin-vue-components/vite"; |
| 7 | +import { ElementPlusResolver } from "unplugin-vue-components/resolvers"; |
8 | 8 |
|
9 | 9 | // https://vitejs.dev/config/ |
10 | 10 | export default defineConfig({ |
11 | | - plugins: [ |
12 | | - vue(), |
13 | | - AutoImport({ |
14 | | - resolvers: [ElementPlusResolver()], |
15 | | - }), |
16 | | - Components({ |
17 | | - resolvers: [ElementPlusResolver()], |
18 | | - }), |
19 | | - ], |
20 | | - resolve: { |
21 | | - alias: { |
22 | | - '@': fileURLToPath(new URL('./src', import.meta.url)) |
23 | | - } |
| 11 | + plugins: [ |
| 12 | + vue(), |
| 13 | + AutoImport({ |
| 14 | + resolvers: [ElementPlusResolver()], |
| 15 | + }), |
| 16 | + Components({ |
| 17 | + resolvers: [ElementPlusResolver()], |
| 18 | + }), |
| 19 | + ], |
| 20 | + resolve: { |
| 21 | + alias: { |
| 22 | + "@": fileURLToPath(new URL("./src", import.meta.url)), |
24 | 23 | }, |
25 | | - //代理http请求,解决跨域问题 |
26 | | - server: { |
27 | | - // host: '192.168.0.66', |
28 | | - host: 'localhost', |
29 | | - port: 5173, |
30 | | - proxy: { |
| 24 | + }, |
| 25 | + //代理http请求,解决跨域问题 |
| 26 | + server: { |
| 27 | + // host: '192.168.0.66', |
| 28 | + // 前端地址 |
| 29 | + host: "localhost", |
| 30 | + port: 5173, |
| 31 | + proxy: { |
31 | 32 | '/api': { //匹配请求路径中含有 /api 的请求 |
32 | 33 | // target: 'http://47.115.226.138:8080', //后端服务地址 |
33 | 34 | target: 'http://localhost:8080', //后端服务地址 |
34 | | - changeOrigin: true, |
35 | | - rewrite: (path) => path.replace(/^\/api/, '') //去除路径中的/api,还原请求路径 |
36 | | - } |
37 | | - } |
| 35 | + changeOrigin: true, |
| 36 | + rewrite: (path) => path.replace(/^\/api/, ""), //去除路径中的/api,还原请求路径 |
| 37 | + }, |
38 | 38 | }, |
39 | | -}) |
| 39 | + }, |
| 40 | +}); |
0 commit comments