New Research: Supply Chain Attack on Axios Pulls Malicious Dependency from npm.Details →
Socket
Book a DemoSign in
Socket

vite-plugin-cy-pxrem

Package Overview
Dependencies
Maintainers
1
Versions
5
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

vite-plugin-cy-pxrem

vite 自定义 px 转 rem

latest
npmnpm
Version
0.0.5
Version published
Maintainers
1
Created
Source

vite-plugin-cy-pxrem

基于 vite-plugin-cy-rem 插件封装的 vite 插件,适用于移动端适配 自动转换 px 为 rem

npm

📦 安装

npm i vite-plugin-cy-pxrem -D

🦄 使用

import cyVitePxToRem from 'vite-plugin-pxrem';

export default defineConfig({
  css: {
    postcss: {
      plugins: [
        cyVitePxToRem({
          //根标签的字体规定为1rem为75px, 750的设计稿 量多少px写多少px
          rootValue: 100,
          //排除在外的选择器列表,匹配到的选择器不会进行单位转换 (默认  ['ignore-'])
          selectorBlackList: ['ignore-'],
          //设置要替换的最小像素值
          minPixelValue: 2,
          //转换后的 rem 保留小数的精度,默认为 5 位小数
          unitPrecision: 5,
          //只对这个列表内的 CSS 属性进行单位转换(若为空,则对所有属性生效)
          propWhiteList: [],
          //在这个列表内的 CSS 属性不进行单位转换
          propBlackList: [],
          //忽略的文件 (默认 /(node_module)/ )
          exclude: /(node_module)/,
          //忽略单个属性的方法,启用ignoreidentifier后,replace将自动设置为true
          ignoreIdentifier: false,
          //是否替换原有的 px 值,如果为 false,则在原有 px 的基础上增加 rem
          replace: true
        })
      ]
    }
  }
});

Keywords

vite-plugin

FAQs

Package last updated on 28 Oct 2025

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts