vite.config.ts 1.1 KB

1234567891011121314151617181920212223242526272829
  1. import { defineConfig } from 'vite'
  2. import vue from '@vitejs/plugin-vue'
  3. import { resolve, dirname } from 'node:path'
  4. import { fileURLToPath } from 'url'
  5. import VueI18nPlugin from '@intlify/unplugin-vue-i18n/vite'
  6. // https://vitejs.dev/config/
  7. export default defineConfig({
  8. server: {
  9. host: '127.0.0.1', // 主机ip
  10. https: false, // 是否开启 https
  11. open: true, // 是否自动在浏览器打开(就是npm run dev后,会自动在浏览器打开这个项目的意思,而不需要我们再手动点一次网页链接)
  12. port: 5173, // 端口号默认值5173
  13. // 代理,即'/api'会被转义成'http://192.168.11.11:8080',作用于接口前缀
  14. proxy: {
  15. '/api': {
  16. target: `http://matrix34.tpddns.cn:60006`, // 后台接口前缀
  17. changeOrigin: true, // 是否允许跨域
  18. secure: false, // 如果是https接口,需要配置这个参数
  19. rewrite: (path) => path.replace(/^\/api/, ''),
  20. },
  21. },
  22. },
  23. plugins: [
  24. vue(),
  25. VueI18nPlugin({
  26. include: resolve(dirname(fileURLToPath(import.meta.url)), './src/i18n/locales/**'),
  27. })
  28. ],
  29. })