vite.config.js 2.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667
  1. import { defineConfig } from 'vite'
  2. import vue from '@vitejs/plugin-vue'
  3. import Pages from 'vite-plugin-pages'
  4. import path from 'path'
  5. import AutoImport from 'unplugin-auto-import/vite'
  6. import Components from 'unplugin-vue-components/vite'
  7. import { ElementPlusResolver } from 'unplugin-vue-components/resolvers'
  8. // https://vitejs.dev/config/
  9. export default defineConfig({
  10. plugins: [
  11. vue(),
  12. Pages(
  13. {
  14. dirs: [
  15. { dir: 'src/page', baseRoute: '' },
  16. { dir: 'src/views', baseRoute: '' }
  17. ],
  18. exclude: ['**/components/*.vue'] // 排除组件
  19. }
  20. ),
  21. AutoImport({
  22. resolvers: [ElementPlusResolver()]
  23. }),
  24. Components({
  25. dts: true,
  26. resolvers: [ElementPlusResolver()]
  27. })
  28. ],
  29. resolve: {
  30. alias: {
  31. '@': path.resolve(path.resolve(), 'src')
  32. }
  33. },
  34. minify: 'terser',
  35. // css: {
  36. // postcss: {
  37. // plugins: [
  38. // postCssPxToViewport({
  39. // unitToConvert: 'px', // 要转化的单位
  40. // viewportWidth: 1920, // UI设计稿的宽度
  41. // unitPrecision: 6, // 转换后的精度,即小数点位数
  42. // propList: ['*'], // 指定转换的css属性的单位,*代表全部css属性的单位都进行转换
  43. // viewportUnit: 'vw', // 指定需要转换成的视窗单位,默认vw
  44. // fontViewportUnit: 'vw', // 指定字体需要转换成的视窗单位,默认vw
  45. // selectorBlackList: ['wrap'], // 指定不转换为视窗单位的类名,
  46. // minPixelValue: 1, // 默认值1,小于或等于1px则不进行转换
  47. // mediaQuery: true, // 是否在媒体查询的css代码中也进行转换,默认false
  48. // replace: true, // 是否转换后直接更换属性值
  49. // landscape: false // 是否处理横屏情况
  50. // })
  51. // ]
  52. // }
  53. // },
  54. server: {
  55. open: true,
  56. proxy: {
  57. '/api': {
  58. // 正式环境地址
  59. // target: 'https://dev.wutongresearch.club/api',
  60. target: 'http://192.168.31.181:8110',
  61. changeOrigin: true,
  62. rewrite: (path) => path.replace(/^\/api/, '')
  63. }
  64. }
  65. }
  66. })