vite.config.js 1.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  1. import { fileURLToPath, URL } from 'node:url'
  2. import { defineConfig } from 'vite'
  3. import vue from '@vitejs/plugin-vue'
  4. import AutoImport from 'unplugin-auto-import/vite'
  5. import Components from 'unplugin-vue-components/vite'
  6. import { ElementPlusResolver } from 'unplugin-vue-components/resolvers'
  7. // https://vite.dev/config/
  8. export default defineConfig({
  9. plugins: [
  10. vue(),
  11. AutoImport({
  12. resolvers: [ElementPlusResolver()],
  13. }),
  14. Components({
  15. resolvers: [ElementPlusResolver()],
  16. }),
  17. ],
  18. resolve: {
  19. alias: {
  20. '@': fileURLToPath(new URL('./src', import.meta.url))
  21. }
  22. },
  23. server: {
  24. host: '192.168.31.78',
  25. port: 9519, // 端口
  26. proxy: {
  27. '/api': { // 请求接口中要替换的标识
  28. target: 'http://192.168.31.78:8088', // 代理地址
  29. changeOrigin: true, // 是否允许跨域
  30. secure: true,
  31. rewrite: (path) => path.replace(/^\/api/, '/api') // api标志替换为''
  32. },
  33. }
  34. },
  35. base: '/',
  36. build: {
  37. chunkSizeWarningLimit: 1000,
  38. outDir: "dist",
  39. assetsDir: "assets", //指定静态资源存放路径
  40. // assetsPublicPath:'',
  41. sourcemap: true, //是否构建source map 文件
  42. terserOptions: {
  43. // 生产环境移除console
  44. compress: {
  45. drop_console: true,
  46. drop_debugger: true,
  47. },
  48. },
  49. }
  50. })