import { resolve } from 'path'; import { defineConfig } from 'vite'; import vue from '@vitejs/plugin-vue'; import styleImport, { VantResolve } from 'vite-plugin-style-import'; function pathResolve(dir) { return resolve(__dirname, dir); } // https://vitejs.dev/config/ export default defineConfig({ base: './', build: { outDir: 'dist/luckywheel' }, resolve:{ alias:[ { find: '@', replacement: pathResolve('src'), } ], }, plugins: [ vue(), styleImport({ // vant libs: [ { libraryName: 'vant', esModule: true, // https://github.com/anncwb/vite-plugin-style-import/issues/52 resolveStyle: (name) => `../es/${name}/style/index`, // resolveStyle: (name) => `../node_modules/vant/es/${name}/style/index`, // 如果报找不到vant可以改用上面的路径 }, ], // nutui // libs: [ // { // libraryName: '@nutui/nutui', // libraryNameChangeCase: 'pascalCase', // resolveStyle: (name) => { // return `@nutui/nutui/dist/packages/${name}/index.scss` // } // } // ] }), ], css: { preprocessorOptions: { scss: { charset: false, // 配置 nutui 全局 scss 变量 // additionalData: `@import "@nutui/nutui/dist/styles/variables.scss";` } } }, server: { proxy: { // 字符串简写写法 // '/api': 'http://www.myblog.com/api', // 选项写法 '/app-api': { target:"https://ios.alipearlhair.com",// 'https:alipearlapp.snjon.com', // "https://ios.alipearlhair.com",//正式站 'http://www.myblog.com', changeOrigin: true, // 设置成false报错 // rewrite: (path) => { // console.log(path,'ooooooooooooo'); // path.replace(/^\/api/, '') // } }, '/api': { target: "http://actapi.snjon.com",//'http://www.myblog.com', changeOrigin: true, // 设置成false报错 // rewrite: (path) => { // console.log(path,'ooooooooooooo'); // path.replace(/^\/api/, '') // } } // 正则表达式写法 // '^/fallback/.*': { // target: 'http://jsonplaceholder.typicode.com', // changeOrigin: true, // rewrite: (path) => path.replace(/^\/fallback/, '') // } } } })