vite.config.ts 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  1. import path from "path";
  2. import { defineConfig } from "vite";
  3. import vue from "@vitejs/plugin-vue";
  4. import vueJsx from "@vitejs/plugin-vue-jsx";
  5. import Components from "unplugin-vue-components/vite";
  6. import { AntDesignVueResolver } from "unplugin-vue-components/resolvers";
  7. import vueSetupExtend from "unplugin-vue-setup-extend-plus/vite";
  8. import { createSvgIconsPlugin } from "vite-plugin-svg-icons";
  9. const resolvePath = (...args: any[]) => {
  10. return path.resolve(__dirname, ...args);
  11. };
  12. // https://vitejs.dev/config/
  13. export default defineConfig({
  14. plugins: [
  15. vue({ reactivityTransform: true }),
  16. vueJsx({}),
  17. Components({ resolvers: [AntDesignVueResolver({ importStyle: false })] }),
  18. createSvgIconsPlugin({
  19. iconDirs: [resolvePath("src/assets/icons")],
  20. symbolId: "icon-[dir]-[name]",
  21. customDomId: "__svg__icons__dom__",
  22. }),
  23. vueSetupExtend(),
  24. ],
  25. resolve: {
  26. extensions: [".vue", ".js", ".ts", ".jsx", ".tsx", ".json"],
  27. alias: [
  28. { find: "@", replacement: resolvePath("src") },
  29. { find: "@api", replacement: resolvePath("src/apis") },
  30. { find: "@imgs", replacement: resolvePath("src/assets/images") },
  31. { find: "@hooks", replacement: resolvePath("src/hooks") },
  32. ],
  33. },
  34. css: {
  35. preprocessorOptions: {
  36. less: {
  37. additionalData(content, context) {
  38. if (context.includes("antd.theme.less")) {
  39. return (
  40. content +
  41. `\r\n@import "${resolvePath("src/assets/less/var.less")}";`
  42. );
  43. }
  44. return (
  45. `@import "${resolvePath("src/assets/less/var.less")}";\r\n` +
  46. content
  47. );
  48. },
  49. javascriptEnabled: true,
  50. },
  51. },
  52. },
  53. server: {
  54. proxy: {
  55. "^/api": {
  56. // target: 'http://192.168.10.39:7100'
  57. target: "http://test.markingtool.cn",
  58. },
  59. },
  60. },
  61. });