🚀 DAY 4 OF LAUNCH WEEK:Introducing Socket Scanning for OpenVSX Extensions.Learn more
Socket
Book a DemoInstallSign in
Socket

@kokojs/plugin-rem

Package Overview
Dependencies
Maintainers
4
Versions
438
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@kokojs/plugin-rem

`@kokojs/plugin-rem` 提供 rem 适配的能力。

latest
npmnpm
Version
4.0.35
Version published
Maintainers
4
Created
Source

Rem 插件

@kokojs/plugin-rem 提供 rem 适配的能力。

安装

yarn add @kokojs/plugin-rem --dev

安装完成后,在 koko.config.js 中添加如下配置:

module.exports = {
  plugins: {
    rem: {},
  },
};

功能

@kokojs/plugin-rem 主要做了两件事:

1. px 转 rem

在编译过程中通过 postcss 的 postcss-pxtorem 插件,将代码中的 px 单位自动转换为 rem 单位。

// input
.image {
  width: 100px;
  height: 75px;
}

// output
.image {
  width: 2rem;
  height: 1.5rem;
}

2. 设定 rem 基准值

@kokojs/plugin-rem 会插入一小段运行时代码,代码执行时,会根据屏幕宽度计算 rem 基准值并设置到根节点上。

<html style="font-size: 50px;">
  <!-- content -->
</html>

配置项

pxtoremOptions

  • Type: object
  • Default: { rootValue: 50, propList: ['*'] }

postcss-pxtorem 插件的配置选项,详见 postcss-pxtorem 文档

维护者

陈嘉涵。

FAQs

Package last updated on 01 Sep 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