vite.config.js 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  1. import { defineConfig } from 'vite'
  2. import vue from '@vitejs/plugin-vue'
  3. import Components from 'unplugin-vue-components/vite'
  4. import { VantResolver } from 'unplugin-vue-components/resolvers'
  5. import postCssPxToRem from 'postcss-pxtorem'
  6. import Pages from 'vite-plugin-pages'
  7. import path from 'path'
  8. // https://vitejs.dev/config/
  9. export default defineConfig({
  10. plugins: [
  11. vue(),
  12. Pages({
  13. dirs: [
  14. { dir: 'src/page', baseRoute: '' },
  15. { dir: 'src/views', baseRoute: '' }
  16. ],
  17. exclude: ['**/component/*.vue'] // 排除组件
  18. }),
  19. Components({
  20. dts: true,
  21. resolvers: [VantResolver()]
  22. })
  23. ],
  24. resolve: {
  25. alias: {
  26. '@': path.resolve(path.resolve(), 'src')
  27. }
  28. },
  29. minify: 'terser',
  30. css: {
  31. postcss: {
  32. plugins: [
  33. postCssPxToRem({
  34. rootValue({ file }) {
  35. return file.indexOf('vant') !== -1 ? 37.5 : 75
  36. },
  37. propList: ['*'],
  38. unitPrecision: 5
  39. })
  40. ]
  41. }
  42. },
  43. server: {
  44. open: true,
  45. proxy: {
  46. '/api': {
  47. // 正式环境地址
  48. // target: 'https://dev.wutongresearch.club/api',
  49. // target: 'https://prod.wutongshucloud.com/api',
  50. target: 'http://192.168.31.181:8110',
  51. changeOrigin: true,
  52. rewrite: path => path.replace(/^\/api/, '')
  53. }
  54. }
  55. }
  56. })