fuyang-jieshou/vite.config.js

52 lines
1.4 KiB
JavaScript
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

import { defineConfig } from 'vite'
import { fileURLToPath, URL } from 'node:url'
import vue from '@vitejs/plugin-vue'
import pxtorem from "postcss-pxtorem";
// https://vitejs.dev/config/
export default defineConfig({
plugins: [vue()],
base: './',
resolve: {
alias: {
'@': fileURLToPath(new URL('./src', import.meta.url))
}
},
server: {
// port: 8080,
host: '0.0.0.0',
cors: true,
proxy: {
'/api': {
target: 'http://172.16.1.253:5001',
changeOrigin: true,
// rewrite: (path) => path.replace(/^\/api/, '')
}
}
},
css: {
preprocessorOptions: {
less: {
math: "always", // 括号内才使用数学计算
globalVars: {
// 全局变量
mainColor: "red",
},
},
},
postcss: {
plugins: [
pxtorem({
rootValue: 192, // 这里写设计稿的宽度/10即可例如设计稿宽度是750px就写75
// vant默认是37.5如果是使用了vant的话可以像下面这样写
// rootValue(res) {
// return res.file.indexOf("vant") !== -1 ? 37.5 : 75;
// },
propList: ['*'], // 需要转换的属性,默认转换所有属性
selectorBlackList: [], // CSS选择器黑名单防止部分选择器被转换
exclude: /\/node_modules\//i, // 忽略包文件转换rem
})
]
}
},
})