vite.config.js 2.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778
  1. import { resolve } from 'path';
  2. import { defineConfig } from 'vite';
  3. import vue from '@vitejs/plugin-vue';
  4. // import styleImport, { VantResolve } from 'vite-plugin-style-import';
  5. import Components from 'unplugin-vue-components/vite';
  6. import {
  7. AntDesignVueResolver,
  8. ElementPlusResolver,
  9. VantResolver,
  10. } from 'unplugin-vue-components/resolvers'
  11. function pathResolve(dir) {
  12. return resolve(__dirname, dir);
  13. }
  14. // https://vitejs.dev/config/
  15. export default defineConfig({
  16. base: './',
  17. build: {
  18. outDir: 'dist/punchin'
  19. },
  20. resolve:{
  21. alias:[
  22. {
  23. find: '@',
  24. replacement: pathResolve('src'),
  25. }
  26. ],
  27. },
  28. plugins: [
  29. vue(),
  30. Components({
  31. resolvers: [
  32. AntDesignVueResolver(),
  33. ElementPlusResolver(),
  34. VantResolver(),
  35. ],
  36. }),
  37. ],
  38. css: {
  39. preprocessorOptions: {
  40. scss: {
  41. charset: false,
  42. // 配置 nutui 全局 scss 变量
  43. // additionalData: `@import "@nutui/nutui/dist/styles/variables.scss";`
  44. }
  45. }
  46. },
  47. server: {
  48. proxy: {
  49. // 字符串简写写法
  50. // '/api': 'http://www.myblog.com/api',
  51. // 选项写法
  52. '/app-api': {
  53. target: 'https:alipearlapp.snjon.com',
  54. // "https://ios.alipearlhair.com",//正式站 'http://www.myblog.com',
  55. changeOrigin: true, // 设置成false报错
  56. // rewrite: (path) => {
  57. // console.log(path,'ooooooooooooo');
  58. // path.replace(/^\/api/, '')
  59. // }
  60. },
  61. '/api': {
  62. target: "http://actapi.snjon.com",//'http://www.myblog.com',
  63. changeOrigin: true, // 设置成false报错
  64. // rewrite: (path) => {
  65. // console.log(path,'ooooooooooooo');
  66. // path.replace(/^\/api/, '')
  67. // }
  68. }
  69. // 正则表达式写法
  70. // '^/fallback/.*': {
  71. // target: 'http://jsonplaceholder.typicode.com',
  72. // changeOrigin: true,
  73. // rewrite: (path) => path.replace(/^\/fallback/, '')
  74. // }
  75. }
  76. }
  77. })