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 🙏

© 2024 – Pkg Stats / Ryan Hefner

postcss-rpx-vw

v1.0.0

Published

PostCSS plugin that makes you to use `rpx` (responsive px) unit in style sheets

Downloads

4

Readme

PostCSS Rpx Loader Build Status

中文说明请见README.zh-hans.md

PostCSS plugin that makes you to use rpx (responsive px) unit in style sheets.

It may replace rem and flexible.js solution.

Features

Copy UI mark to code

Enables you to directly copy the px value in marked UI to your CSS (or other preprocessors), and the loader will compile them responsively without manually converting px values to rem or other units.

Better performance

PostCSS will handle the unit conversion, and you needn't import any JS libs in the client. In other words, a better performance.

No conflict with third-party UI libs

It doesn't depend on <html data-dpr="", therefore, you won't get oversized or shrinked third-party UI lib.

No overwriting exsiting units

Since rpx is a new unit, existing units like rem, em and px are not overwritten and work as what they originally does.

VW core

It performs well on retina screens, and it well resolves real 1px problem, since the essence of rpx is vw.

Usage (Take SCSS for example)

Ensure that you've installed postcss-loader and the PostCSS plugin of your preferred preprocessor.

Run npm i postcss-rpx-loader -D in the root directory of your project.

In webpack.config.js, invoke postcss-loader.

module.exports = {
  module: {
    rules: [{
    test: /\.scss$/,
    use: [
      'vue-style-loader',
      'css-loader',
      'postcss-loader', // If you use a preprocessor,please insert `postcss-loader`before the loader of the preprocessor
      'sass-loader'
    ]
    }]
  }
}

Create postcss.config.js in the root directory of your project and write

module.exports = {
  syntax: 'postcss-scss',
  plugins: [
    // Default UI width is 750px
    require('postcss-rpx-loader')
    // May accept a parameter which indicates UI width
    // require('postcss-rpx-loader')(1080)
  ]
}

Now you can use rpx in your style sheets.

div {
  /* If it is 50px in the marked UI, you just need to write 50rpx */
  height: 50rpx;  
}
div {
  /* What you get */
  /* In devices with different screen widths, you will get uniform visual effects */
  height: 6.67vw;
}

Integrate with Vue CLI

Run npm i postcss-rpx-loader -D in the root directory of your project.

In package.json

{
  "name": "",
  "version": "",
  // ...
  "postcss": {
    "plugins": {
      "autoprefixer": {},
      "postcss-rpx-loader": {} // Add this
    }
  }
}