vite.config.js 2.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283
  1. import { fileURLToPath, URL } from "node:url";
  2. import fs from 'node:fs';
  3. import { defineConfig } from "vite";
  4. import vue from "@vitejs/plugin-vue";
  5. import vueDevTools from "vite-plugin-vue-devtools";
  6. import vueJsx from "@vitejs/plugin-vue-jsx";
  7. import { createSvgIconsPlugin } from "vite-plugin-svg-icons";
  8. import { codeInspectorPlugin } from 'code-inspector-plugin';
  9. import AutoImport from 'unplugin-auto-import/vite'
  10. import { resolve } from "path";
  11. // https://vite.dev/config/
  12. export default defineConfig({
  13. base: "./",
  14. plugins: [
  15. vue(),
  16. vueJsx(),
  17. AutoImport({
  18. imports:[
  19. 'vue',
  20. 'vue-router'
  21. ]
  22. }),
  23. // vueDevTools(),
  24. createSvgIconsPlugin({
  25. // 指定需要缓存的图标文件夹
  26. iconDirs: [ resolve(process.cwd(), "src/assets/svg")],
  27. // 指定symbolId格式
  28. symbolId: "icon-[dir]-[name]",
  29. }),
  30. codeInspectorPlugin({
  31. bundler: 'vite',
  32. }),
  33. ],
  34. resolve: {
  35. alias: {
  36. "@": fileURLToPath(new URL("./src", import.meta.url)),
  37. },
  38. },
  39. css: {
  40. // css预处理器
  41. preprocessorOptions: {
  42. less: {
  43. charset: false, // 解决中文乱码
  44. javascriptEnabled: true,
  45. additionalData:
  46. '@import "@/assets/css/global.less";@import "@/assets/css/theme.less";',
  47. },
  48. },
  49. },
  50. build: {
  51. minify: true, // 生产环境不生成sourcemap
  52. target: "es2015",
  53. // 警报门槛,限制大文件大小
  54. chunkSizeWarningLimit: 5000,
  55. rollupOptions: {
  56. external: [], // 外部化处理那些你不想打包进库的依赖
  57. // 静态资源分类打包
  58. output: {
  59. chunkFileNames: "static/js/[name]-[hash].js",
  60. entryFileNames: "static/js/[name]-[hash].js",
  61. assetFileNames: "static/[ext]/[name]-[hash].[ext]",
  62. },
  63. },
  64. },
  65. server: {
  66. host: true,
  67. port: 5173,
  68. open: true,
  69. cors: true,
  70. hmr: true,
  71. proxy: {
  72. "^/api": {
  73. target:"https://wallet.angeltokens.io",
  74. changeOrigin: true,
  75. // secure: false,
  76. }
  77. },
  78. },
  79. });