71 lines
2.8 KiB
JavaScript
71 lines
2.8 KiB
JavaScript
import { defineConfig } from 'vite'
|
||
import uni from '@dcloudio/vite-plugin-uni'
|
||
import AutoImport from 'unplugin-auto-import/vite'
|
||
import Components from 'unplugin-vue-components/vite'
|
||
import { VantResolver } from '@vant/auto-import-resolver'
|
||
import postcsspxtoviewport8plugin from 'postcss-px-to-viewport-8-plugin'
|
||
// import path from 'path'
|
||
import { resolve } from 'path'
|
||
// https://vitejs.dev/config/
|
||
export default defineConfig({
|
||
plugins: [
|
||
uni(),
|
||
// styleImport({
|
||
// resolves: [VantResolve()],
|
||
// }),
|
||
|
||
AutoImport({
|
||
resolvers: [VantResolver()],
|
||
}),
|
||
Components({
|
||
resolvers: [VantResolver()],
|
||
}),
|
||
require('postcss-px-to-viewport'),
|
||
],
|
||
resolve: {
|
||
api: 'modern-compiler',
|
||
alias: {
|
||
'@': resolve(__dirname, 'src'),
|
||
},
|
||
},
|
||
server: {
|
||
port: '8101',
|
||
proxy: {
|
||
// 在此处编写代理规则
|
||
'/api': {
|
||
target: 'http://36.33.26.201:17788/proxyApi',
|
||
// target: 'http://192.168.2.123:28080',
|
||
// target: 'http://192.168.2.122:28080',
|
||
// target: 'http://192.168.0.244:28580', // 测试服务
|
||
changeOrigin: true,
|
||
rewrite: (path) => {
|
||
return path.replace(/\/api/, '')
|
||
},
|
||
},
|
||
},
|
||
},
|
||
css: {
|
||
postcss: {
|
||
plugins: [
|
||
postcsspxtoviewport8plugin({
|
||
unitToConvert: 'px',
|
||
viewportWidth: 375,
|
||
unitPrecision: 5, // 单位转换后保留的精度
|
||
propList: ['*'], // 能转化为vw的属性列表
|
||
viewportUnit: 'vw', // 希望使用的视口单位
|
||
fontViewportUnit: 'vw', // 字体使用的视口单位
|
||
selectorBlackList: [], // 需要忽略的CSS选择器,不会转为视口单位,使用原有的px等单位。
|
||
minPixelValue: 1, // 设置最小的转换数值,如果为1的话,只有大于1的值会被转换
|
||
mediaQuery: true, // 媒体查询里的单位是否需要转换单位
|
||
replace: true, // 是否直接更换属性值,而不添加备用属性
|
||
exclude: [/node_modules\/vant/i], // 忽略某些文件夹下的文件或特定文件,例如 'node_modules' 下的文件
|
||
include: [], // 如果设置了include,那将只有匹配到的文件才会被转换
|
||
landscape: false, // 是否添加根据 landscapeWidth 生成的媒体查询条件 @media (orientation: landscape)
|
||
landscapeUnit: 'vw', // 横屏时使用的单位
|
||
landscapeWidth: 1024, // 横屏时使用的视口宽度
|
||
}),
|
||
],
|
||
},
|
||
},
|
||
})
|