import { defineConfig } from 'vite' import react from '@vitejs/plugin-react' import postcssPxToViewport from 'postcss-px-to-viewport'; // https://vitejs.dev/config/ export default defineConfig({ plugins: [react()], server: { host: '0.0.0.0', // 允许外部网络访问 port: 3000, // 更改此处的端口号 }, resolve: { alias: { '@': '/src', // 配置@指向src目录 }, }, css: { postcss: { plugins: [ postcssPxToViewport({ viewportWidth: 375, // 视口宽度,根据设计图的大小 viewportHeight: 1000, // 视口高度,根据设计图的大小 unitPrecision: 6,// 保留小数点 viewportUnit: 'vw', // 单位 selectorBlackList: [], // 排除的类 minPixelValue: 1, // px的最小单位 mediaQuery: false, // 排除媒体查询 landscapeUnit: 'vw', // 横屏单位 fontViewportUnit: 'vw', // 字体属性单位 // exclude: /(\/|\\)(node_modules)(\/|\\)/, // 排除 node_modules 目录下的文件 }), // 其他 PostCSS 插件配置 ], }, }, })