vite.config.ts 1.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071
  1. import { defineConfig, loadEnv } from 'vite'
  2. import vue from '@vitejs/plugin-vue'
  3. import ViteComponents from 'unplugin-vue-components/vite'
  4. import { AntDesignVueResolver } from 'unplugin-vue-components/resolvers'
  5. import DefineOptions from 'unplugin-vue-define-options/vite'
  6. import { resolve } from 'path'
  7. // const proxy = {
  8. // '/api': {
  9. // target: 'https://v4-test.4dkankan.com/',
  10. // changeOrigin: true,
  11. // rewrite: path => path.replace(/^\/api/, '')
  12. // }
  13. // }
  14. // https://vitejs.dev/config/
  15. export default ({ mode }) =>
  16. defineConfig({
  17. base: './',
  18. plugins: [
  19. vue(),
  20. DefineOptions(),
  21. ViteComponents({
  22. resolvers: [
  23. AntDesignVueResolver({ resolveIcons: true, importStyle: 'less' })
  24. ],
  25. dts: 'src/components.d.ts'
  26. })
  27. ],
  28. css: {
  29. preprocessorOptions: {
  30. less: {
  31. javascriptEnabled: true,
  32. modifyVars: {
  33. 'primary-color': '#0076F6',
  34. 'link-color': '#0076F6',
  35. 'border-radius-base': '2px'
  36. }
  37. }
  38. }
  39. },
  40. resolve: {
  41. alias: [
  42. {
  43. find: 'vue-i18n',
  44. replacement: 'vue-i18n/dist/vue-i18n.cjs.js'
  45. },
  46. {
  47. find: '@',
  48. replacement: resolve(__dirname, './src')
  49. },
  50. {
  51. find: '#',
  52. replacement: resolve(__dirname, './types')
  53. }
  54. ]
  55. },
  56. server: {
  57. host: '0.0.0.0',
  58. port: 5173,
  59. open: true,
  60. proxy: {
  61. '/api': {
  62. target: loadEnv(mode, process.cwd()).VITE_BASE_API_URL,
  63. changeOrigin: true,
  64. rewrite: path => path.replace(/^\/api/, '')
  65. }
  66. }
  67. }
  68. })