vite.config.ts 1.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667
  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. assetsInclude: ['**/*.TTF', '**/*.otf', 'SourceHanSansCN-Bold.otf', 'SourceHanSansCN-Regular.otf', 'STXINGKA.TTF'],
  47. server: {
  48. host: true,
  49. port: 8989,
  50. proxy: {
  51. "/zd-api": {
  52. // target: "https://open.api.luojigou.vip",
  53. target: "https://open.test.luojigou.vip",
  54. changeOrigin: true,
  55. rewrite: (path) => path.replace(/^\/zd-api/, ""),
  56. },
  57. },
  58. },
  59. resolve: {
  60. alias,
  61. // 使用路径别名时想要省略的后缀名,可以自己 增减
  62. extensions: [".js", ".json", ".ts", ".vue"],
  63. },
  64. });