vite.config.js 2.2 KB

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