114 lines
3.8 KiB
TypeScript
114 lines
3.8 KiB
TypeScript
import {defineConfig} from 'vite'
|
||
import vue from '@vitejs/plugin-vue'
|
||
import Components from 'unplugin-vue-components/vite'
|
||
import {VantResolver} from "unplugin-vue-components/resolvers";
|
||
import {resolve} from "path";
|
||
// @ts-ignore
|
||
import postcsspxtoviewport from 'postcss-px-to-viewport-8-plugin'
|
||
|
||
function pathResolve(dir: string) {
|
||
return resolve(process.cwd(), '.', dir);
|
||
}
|
||
|
||
|
||
export default defineConfig({
|
||
base: '/',
|
||
esbuild: {},
|
||
plugins: [
|
||
vue(),
|
||
Components({
|
||
resolvers: [VantResolver()]
|
||
})
|
||
],
|
||
resolve: {
|
||
alias: [
|
||
{
|
||
find: /\/#\//,
|
||
replacement: pathResolve('types') + '/',
|
||
},
|
||
{
|
||
find: '@',
|
||
replacement: pathResolve('src') + '/',
|
||
},
|
||
],
|
||
dedupe: ['vue'],
|
||
},
|
||
server: {
|
||
host: true,
|
||
port: 9528,
|
||
proxy: {
|
||
'/api': {
|
||
target: ' http://dk.qiqizl.com',
|
||
// target: 'http://localhost:8082',
|
||
changeOrigin: true,
|
||
ws: true,
|
||
rewrite: (path) => path.replace(new RegExp(`^/api`), '/api'),
|
||
secure: false
|
||
},
|
||
'/customer': {
|
||
target: 'http://localhost:8090',
|
||
changeOrigin: true,
|
||
ws: true,
|
||
rewrite: (path) => path.replace(new RegExp(`^/customer`), '/customer'),
|
||
secure: false
|
||
},
|
||
'/app': {
|
||
target: 'http://localhost:8090',
|
||
changeOrigin: true,
|
||
ws: true,
|
||
rewrite: (path) => path.replace(new RegExp(`^/app`), '/app'),
|
||
secure: false
|
||
},
|
||
'/v2': {
|
||
target: 'http://localhost:8090',
|
||
changeOrigin: true,
|
||
ws: true,
|
||
rewrite: (path) => path.replace(new RegExp(`^/v2`), '/v2'),
|
||
secure: false
|
||
}
|
||
}
|
||
},
|
||
css: {
|
||
postcss: {
|
||
plugins: [
|
||
postcsspxtoviewport({
|
||
unitToConvert: "px", // 要转化的单位
|
||
viewportWidth: 375, // UI设计稿的宽度
|
||
unitPrecision: 6, // 转换后的精度,即小数点位数
|
||
propList: ["*"], // 指定转换的css属性的单位,*代表全部css属性的单位都进行转换
|
||
viewportUnit: "vw", // 指定需要转换成的视窗单位,默认vw
|
||
fontViewportUnit: "vw", // 指定字体需要转换成的视窗单位,默认vw
|
||
selectorBlackList: ["ignore"], // 指定不转换为视窗单位的类名,
|
||
minPixelValue: 1, // 默认值1,小于或等于1px则不进行转换
|
||
mediaQuery: true, // 是否在媒体查询的css代码中也进行转换,默认false
|
||
replace: true, // 是否转换后直接更换属性值
|
||
exclude: [/^(?!.*node_modules\/vant)/], // 设置忽略文件,用正则做目录名匹配
|
||
landscape: false, // 是否处理横屏情况
|
||
}),
|
||
postcsspxtoviewport({
|
||
unitToConvert: "px", // 要转化的单位
|
||
viewportWidth: 750, // UI设计稿的宽度
|
||
unitPrecision: 6, // 转换后的精度,即小数点位数
|
||
propList: ["*"], // 指定转换的css属性的单位,*代表全部css属性的单位都进行转换
|
||
viewportUnit: "vw", // 指定需要转换成的视窗单位,默认vw
|
||
fontViewportUnit: "vw", // 指定字体需要转换成的视窗单位,默认vw
|
||
selectorBlackList: ["ignore"], // 指定不转换为视窗单位的类名,
|
||
minPixelValue: 1, // 默认值1,小于或等于1px则不进行转换
|
||
mediaQuery: true, // 是否在媒体查询的css代码中也进行转换,默认false
|
||
replace: true, // 是否转换后直接更换属性值
|
||
exclude: [/node_modules\/vant/i], // 设置忽略文件,用正则做目录名匹配
|
||
landscape: false, // 是否处理横屏情况
|
||
})
|
||
]
|
||
}
|
||
},
|
||
build: {
|
||
// minify: 'terser',
|
||
target: 'es2015',
|
||
cssTarget: 'chrome80',
|
||
outDir: 'dist',
|
||
reportCompressedSize: false,
|
||
chunkSizeWarningLimit: 2000,
|
||
},
|
||
})
|