独墅湖高教创新区危化品智慧管控平台(新危化品)
马宇豪
2025-04-21 05cccb157fa461c1ce17cbeb9b00ed5396491ca8
vite.config.js
@@ -1,6 +1,8 @@
import { defineConfig, loadEnv } from 'vite'
import path from 'path'
import createVitePlugins from './vite/plugins'
import vue from '@vitejs/plugin-vue';
import postcssPxtorem from 'postcss-pxtorem'; // 使用 import 导入
// https://vitejs.dev/config/
export default defineConfig(({ mode, command }) => {
@@ -50,7 +52,37 @@
                }
              }
            }
          }
          },
          // postcssPxtorem({
          //   rootValue: 19.2,
          //   propList: ['*'],
          //   // 只转换带有特定类名的样式
          //   include: (filePath, content) => {
          //     return (
          //         filePath.includes('hazardousChemicals/bigScreen/index.vue') &&
          //         content.includes('data-dashboard')
          //     );
          //   }
          // })
          postcssPxtorem({
            rootValue: 37.5,
            propList: ['*'],
            selectorBlackList: [/^html$/],
            // 精确匹配大屏组件路径
            include: (filePath, content = '') => {
              return (
                  content.includes('postcss-pxtorem-enabled')
              );
            },
            // 排除其他所有文件
            exclude: (filePath, content = '') => {
              return !(
                  content.includes('postcss-pxtorem-enabled')
              );
            },
            mediaQuery: false,
            minPixelValue: 3
          })
        ]
      }
    }