123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384 |
- import { defineConfig, loadEnv } from 'vite'
- import vue from '@vitejs/plugin-vue'
- //1、 导入 path 模块,帮助我们解析路径
- import { resolve } from 'path'
- //2-1 自动导入vue中hook reactive ref等
- import AutoImport from 'unplugin-auto-import/vite'
- //2-2 自动导入ui-组件 比如说ant-design-vue element-plus等
- import Components from 'unplugin-vue-components/vite'
- //3、vue3语法糖
- import VueSetupExtend from 'vite-plugin-vue-setup-extend'
- // https://vitejs.dev/config/
- export default defineConfig(({ mode }) => {
- const config = loadEnv(mode, './');
- console.log(config);
- return {
- base: "./",
- plugins: [
- vue(),
- AutoImport({
- //安装两行后你会发现在组件中不用再导入ref,reactive等
- imports: ['vue', 'vue-router'],
- //存放的位置
- dts: "src/auto-import.d.ts",
- }),
- Components({
- // 引入组件的,包括自定义组件,存放的位置
- dts: "src/components.d.ts",
- }),
- VueSetupExtend(),
- ],
- //1、 ↓解析配置
- resolve: {
- // ↓路径别名
- alias: {
- '@': resolve('src')
- }
- },
- //代理
- server: {
- proxy: {
- '/api': {
- // target: 'http://192.168.0.131:8187/TransServlet',//配置文件获取地址
- target: 'https://www.adicn.com/disaster',
- secure: false, //接受使用https
- changeOrigin: true, //允许跨域
- ws: false, //使用websocket
- rewrite: (path) => path.replace(/^\/api/, '')
- },
- '/disaster': {
- // target: 'http://192.168.0.131:8187/TransServlet',//配置文件获取地址
- target: 'https://www.adicn.com/disaster',
- secure: false, //接受使用https
- changeOrigin: true, //允许跨域
- ws: false, //使用websocket
- rewrite: (path) => path.replace(/^\/disaster/, '')
- },
- '/file': {
- // target: 'http://192.168.0.15:8081/', // 后端接口地址
- target: 'http://192.168.0.43:2201/',
- secure: false, //接受使用https
- changeOrigin: true, //允许跨域
- ws: false, //使用websocket
- pathRewrite: { // 路径重写
- '^/file': ''
- }
- }, '/websokct': {
- target: 'http://192.168.0.131:8081/',
- // target: 'http://192.168.0.43:8081/',
- // target: 'https://www.gzchain.org.cn/managersvc/', //后端接口地址
- secure: false, //接受使用https
- },
- }
- }
- }
- })
|