vite.config.ts 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116
  1. import vue from "@vitejs/plugin-vue";
  2. import { resolve } from "path";
  3. import { defineConfig } from "vite";
  4. import legacy from '@vitejs/plugin-legacy';
  5. import { terser } from 'rollup-plugin-terser';
  6. // https://vitejs.dev/config/
  7. const pathResolve = (dir: string): string => {
  8. return resolve(__dirname, ".", dir);
  9. };
  10. const alias: Record<string, string> = {
  11. "@": pathResolve("src"),
  12. };
  13. export default defineConfig({
  14. plugins: [
  15. vue(),
  16. legacy({
  17. targets: ['chrome 52'],
  18. additionalLegacyPolyfills: ['regenerator-runtime/runtime'],
  19. renderLegacyChunks: true,
  20. polyfills: [
  21. 'es.symbol',
  22. 'es.promise',
  23. 'es.promise.finally',
  24. 'es/map',
  25. 'es/set',
  26. 'es.array.filter',
  27. 'es.array.for-each',
  28. 'es.array.flat-map',
  29. 'es.object.define-properties',
  30. 'es.object.define-property',
  31. 'es.object.get-own-property-descriptor',
  32. 'es.object.get-own-property-descriptors',
  33. 'es.object.keys',
  34. 'es.object.to-string',
  35. 'web.dom-collections.for-each',
  36. 'esnext.global-this',
  37. 'esnext.string.match-all'
  38. ]
  39. }),
  40. terser()
  41. ],
  42. base: "./",
  43. css: {
  44. preprocessorOptions: {
  45. scss: {
  46. /**
  47. * 单行溢出隐藏 @include single-hide();
  48. *
  49. * 多行溢出隐藏 @include multi-hide(3);
  50. *
  51. * flex布局垂直水平居中 @include flex-center();
  52. *
  53. */
  54. additionalData: `
  55. @mixin flex-center() {
  56. display: flex;
  57. justify-content: center;
  58. align-items: center;
  59. }
  60. @mixin single-hide() {
  61. overflow: hidden;
  62. white-space: nowrap;
  63. text-overflow: ellipsis;
  64. }
  65. @mixin multi-hide($num) {
  66. overflow: hidden;
  67. display: -webkit-box;
  68. -webkit-box-orient: vertical;
  69. -webkit-line-clamp: $num;
  70. }
  71. `,
  72. },
  73. },
  74. },
  75. assetsInclude: ['**/*.TTF', '**/*.otf', 'SourceHanSansCN-Bold.otf', 'SourceHanSansCN-Regular.otf', 'STXINGKA.TTF'],
  76. server: {
  77. host: true,
  78. port: 8989,
  79. proxy: {
  80. "/zd-api": {
  81. target: "https://open.api.luojigou.vip",
  82. // target: "https://open.test.luojigou.vip",
  83. changeOrigin: true,
  84. rewrite: (path) => path.replace(/^\/zd-api/, ""),
  85. },
  86. },
  87. },
  88. resolve: {
  89. alias,
  90. // 使用路径别名时想要省略的后缀名,可以自己 增减
  91. extensions: [".js", ".json", ".ts", ".vue"],
  92. },
  93. esbuild: {
  94. tsconfigRaw: false
  95. },
  96. build:{
  97. rollupOptions: {
  98. onwarn(warning, warn) {
  99. // 忽略所有警告
  100. return
  101. }
  102. },
  103. reportCompressedSize: false,
  104. chunkSizeWarningLimit: Infinity,
  105. }
  106. // build: {
  107. // target: 'esnext', // 输出 ESNext 代码
  108. // minify: false, // 禁用代码压缩
  109. // terserOptions: {
  110. // 'compress': false
  111. // } // 禁用 terser 压缩
  112. // }
  113. });