npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

postcss-px-to-remjs

v1.0.3

Published

postcss px to rem plugins, with html-webpack-remjs

Readme

postcss-px-to-remjs

一个用来通过rem适配移动端的插件,包括 postcss 的插件 postcss-px-to-rem 和 HtmlWepbackPlugin 的钩子插件 HtmlWebpackPxToRemPlugin 两部分组成,本插件主要用在webpack下

简介

该插件会通过两个部分来完成适配工作,postcss插件部分主要是用来替换css文件中的px为rem,HtmlWebpackPlugin 钩子插件主要是用来向html的头部注入简版的rem.js代码用以动态改变根字体大小,postcss-px-to-viewport功能完成

输入(设计稿宽度为1080px)

.class{
  width:1080px;
  padding:10px;
  margin:2px;
  font-size:14px;
  border-width:0;
}

输出

.class{
  width:10.8rem;
  padding:0.1rem;
  margin:0.02rem;
  font-size:0.14rem;
  border-width:0;
}

安装

npm i postcss-px-to-remjs --save-dev

yarn add postcss-px-to-remjs --dev

使用

配置postcss的plugins

module.exports = {
  plugins:{
    //...
    'postcss-px-to-remjs': {
      //options
    }
  }
}

默认参数

let defaults = {
  propList: ['*'],//能够转化为rem的属性列表,默认是所有
  selectorBlackList: [],//需要忽略的CSS选择器
  replace: true,//是否直接更换属性值,而不添加备用属性
  exclude: [],//忽略某些文件夹下的文件或特定文件
};

本插件仅支持以上属性,可参考 postcss-px-to-viewport 插件中对应属性介绍

配置Webpack的plugins

const HtmlWebpackPlugin = require('html-webpack-plugin');
const HtmlWebpackPxToRemPlugin = require('postcss-px-to-remjs/plugins/html-webpack-px-to-rem-plugin');

module.exports = {
  //...
  plugins:[
     new HtmlWebpackPlugin({
       template: "./index.html",
       filename: "./dist/index.html",
       chunks: ["index"]
     }),
    new HtmlWebpackPxToRemPlugin({
      //options
    })
  ]
}

默认参数

{
  designWidth: 1080,//设计稿宽度
  maxPageWidth:1080 //允许页面显示的最大宽度,此宽度是用来限制页面无限制放大,比如将手机页面在pad打开,防止页面中个元素尺寸过大
}