vite.config.ts 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566
  1. import { defineConfig } from "vite";
  2. import vue from "@vitejs/plugin-vue";
  3. import { resolve } from "path";
  4. // https://vitejs.dev/config/
  5. const pathResolve = (dir: string): string => {
  6. return resolve(__dirname, ".", dir);
  7. };
  8. const alias: Record<string, string> = {
  9. "@": pathResolve("src"),
  10. };
  11. export default defineConfig({
  12. plugins: [vue()],
  13. base: "./",
  14. css: {
  15. preprocessorOptions: {
  16. scss: {
  17. /**
  18. * 单行溢出隐藏 @include single-hide();
  19. *
  20. * 多行溢出隐藏 @include multi-hide(3);
  21. *
  22. * flex布局垂直水平居中 @include flex-center();
  23. *
  24. */
  25. additionalData: `
  26. @mixin flex-center() {
  27. display: flex;
  28. justify-content: center;
  29. align-items: center;
  30. }
  31. @mixin single-hide() {
  32. overflow: hidden;
  33. white-space: nowrap;
  34. text-overflow: ellipsis;
  35. }
  36. @mixin multi-hide($num) {
  37. overflow: hidden;
  38. display: -webkit-box;
  39. -webkit-box-orient: vertical;
  40. -webkit-line-clamp: $num;
  41. }
  42. `,
  43. },
  44. },
  45. },
  46. server: {
  47. host: true,
  48. port: 8989,
  49. proxy: {
  50. "/zd-api": {
  51. // target: "https://open.api.luojigou.vip",
  52. target: "https://open.test.luojigou.vip",
  53. changeOrigin: true,
  54. rewrite: (path) => path.replace(/^\/zd-api/, ""),
  55. },
  56. },
  57. },
  58. resolve: {
  59. alias,
  60. // 使用路径别名时想要省略的后缀名,可以自己 增减
  61. extensions: [".js", ".json", ".ts", ".vue"],
  62. },
  63. });