65 lines
1.8 KiB
JavaScript
65 lines
1.8 KiB
JavaScript
import { defineConfig } from 'vite'
|
||
import vue from '@vitejs/plugin-vue'
|
||
import path from "path";
|
||
import pxtorem from "postcss-pxtorem";
|
||
// https://vitejs.dev/config/
|
||
export default defineConfig({
|
||
plugins: [vue()],
|
||
define: {
|
||
'process.env': process.env
|
||
},
|
||
resolve: {
|
||
// 配置路径别名
|
||
alias: {
|
||
'@': path.resolve(__dirname, './src'),
|
||
},
|
||
extensions: ['.mjs', '.js', '.ts', '.jsx', '.tsx', '.json', '.vue'],
|
||
},
|
||
// vite 相关配置
|
||
server: {
|
||
port: 8801,
|
||
host: true,
|
||
open: true,
|
||
proxy: {
|
||
// https://cn.vitejs.dev/config/#server-proxy
|
||
'/dev-api': {
|
||
target: 'http://172.16.1.106:5005/',
|
||
changeOrigin: true,
|
||
rewrite: (p) => p.replace(/^\/dev-api/, '')
|
||
},
|
||
'/api': {
|
||
target: 'http://172.16.1.106:5005/api',
|
||
changeOrigin: true,
|
||
rewrite: (p) => p.replace(/^\/api/, '')
|
||
},
|
||
'/preview': {
|
||
target: 'http://172.16.1.106:5005/',
|
||
changeOrigin: true,
|
||
rewrite: (p) => p.replace(/^\/preview/, '')
|
||
}
|
||
}
|
||
},
|
||
// 全局配置scss方法
|
||
css: {
|
||
preprocessorOptions: {
|
||
scss: {
|
||
additionalData: `@import "@/assets/scss/common.scss";`,
|
||
},
|
||
},
|
||
},
|
||
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
|
||
})
|
||
]
|
||
}
|
||
})
|