dhjk/vite.config.js

48 lines
1.3 KiB
JavaScript

import { defineConfig } from "vite";
import { fileURLToPath, URL } from 'url'
import vue from "@vitejs/plugin-vue";
import AutoImport from "unplugin-auto-import/vite";
import Components from "unplugin-vue-components/vite";
// import { ElementPlusResolver } from "unplugin-vue-components/resolvers";
// https://vitejs.dev/config/
export default defineConfig({
plugins: [
vue(),
AutoImport({
// resolvers: [ElementPlusResolver()],
}),
Components({
// resolvers: [ElementPlusResolver()],
directoryAsNamespace: true
}),
],
resolve: {
extensions: ['.js', '.vue'],
alias: {
'@': fileURLToPath(new URL('./src', import.meta.url))
}
},
server: {
host: '0.0.0.0', // 解决“vite use `--host` to expose”-- 0.0.0.0 将监听所有地址
proxy: {
'/api': {
// target: 'http://10.0.0.29:9999',
// target: 'http://demo35.ydool.net/',
target: 'http://192.168.1.14:7777',
// target: 'http://10.0.0.63:7777', // 刘进
changeOrigin: true,
// rewrite: (path) => path.replace(/^\/api/, '')
// ws: true,// 开启webSocket
},
'/metadata': {
target: 'http://192.168.1.14:7777',
changeOrigin: true,
rewrite: (path) => path.replace(/^\/api/, '')
// ws: true,// 开启webSocket
}
}
}
});