vite.config.js 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293
  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. function pathResolve(dir) {
  6. return resolve(__dirname, dir);
  7. }
  8. // https://vitejs.dev/config/
  9. export default defineConfig({
  10. base: './',
  11. build: {
  12. outDir: 'dist/luckywheel'
  13. },
  14. resolve:{
  15. alias:[
  16. {
  17. find: '@',
  18. replacement: pathResolve('src'),
  19. }
  20. ],
  21. },
  22. plugins: [
  23. vue(),
  24. styleImport({
  25. // vant
  26. libs: [
  27. {
  28. libraryName: 'vant',
  29. esModule: true,
  30. // https://github.com/anncwb/vite-plugin-style-import/issues/52
  31. resolveStyle: (name) => `../es/${name}/style/index`,
  32. // resolveStyle: (name) => `../node_modules/vant/es/${name}/style/index`, // 如果报找不到vant可以改用上面的路径
  33. },
  34. ],
  35. // nutui
  36. // libs: [
  37. // {
  38. // libraryName: '@nutui/nutui',
  39. // libraryNameChangeCase: 'pascalCase',
  40. // resolveStyle: (name) => {
  41. // return `@nutui/nutui/dist/packages/${name}/index.scss`
  42. // }
  43. // }
  44. // ]
  45. }),
  46. ],
  47. css: {
  48. preprocessorOptions: {
  49. scss: {
  50. charset: false,
  51. // 配置 nutui 全局 scss 变量
  52. // additionalData: `@import "@nutui/nutui/dist/styles/variables.scss";`
  53. }
  54. }
  55. },
  56. server: {
  57. proxy: {
  58. // 字符串简写写法
  59. // '/api': 'http://www.myblog.com/api',
  60. // 选项写法
  61. '/app-api': {
  62. target:"https://ios.alipearlhair.com",// 'https:alipearlapp.snjon.com',
  63. // "https://ios.alipearlhair.com",//正式站 'http://www.myblog.com',
  64. changeOrigin: true, // 设置成false报错
  65. // rewrite: (path) => {
  66. // console.log(path,'ooooooooooooo');
  67. // path.replace(/^\/api/, '')
  68. // }
  69. },
  70. '/api': {
  71. target: "http://actapi.snjon.com",//'http://www.myblog.com',
  72. changeOrigin: true, // 设置成false报错
  73. // rewrite: (path) => {
  74. // console.log(path,'ooooooooooooo');
  75. // path.replace(/^\/api/, '')
  76. // }
  77. }
  78. // 正则表达式写法
  79. // '^/fallback/.*': {
  80. // target: 'http://jsonplaceholder.typicode.com',
  81. // changeOrigin: true,
  82. // rewrite: (path) => path.replace(/^\/fallback/, '')
  83. // }
  84. }
  85. }
  86. })