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-rfs-autopilot

v1.1.3

Published

A PostCSS plugin that will automagically mark your CSS up with rfs() for RFS

Downloads

15

Readme

PostCSS RFS Autopilot terminal screenshot

PostCSS RFS Autopilot

Maintainability Test Coverage Known Vulnerabilities Codacy Badge

A PostCSS plugin that automagically mark your CSS up with rfs() for RFS, helping you achieve a responsive layout efficiently and consistently.

/* Original Input */
.foo {
    font-size: 4em;
}
/* After the transformation of RFS Autopilot but before RFS*/
.foo {
  font-size: rfs(4em);
}
/* After the transformation of RFS*/
.foo {
  font-size: calc(1.525rem + 3.3vw);
}

@media (min-width: 1200px) {
  .foo {
    font-size: 4rem;
  }
}

Problem

RFS is a great unit resizing engine that helps you build responsive CSS layout, but writing rfs() everywhere manually is a pain in the ass.

With this plugin, you just need to declare rules you want to apply rfs() to, and it will do the heavy-lifting for you.

Made in Hong Kong :free: :free:

This plugin is made with love by a Hong Konger.

Installation

As this plugin is a PostCSS plugin, you need to install and set up PostCSS first before use it. If you haven't used PostCSS before, set it up according to official docs.

Input this command in terminal and download this PostCSS plugin.

npm i postcss-rfs-autopilot

RFS is treated as an external dependency for this plugin, thus you would need to download and include it manually in your PostCSS config as usual.

npm i rfs

After you have installed this plugin, require it before RFS in your PostCSS configuration files, or the place where you config PostCSS in your environment

//postcss.config.js or other files you use to config PostCSS

module.exports = {
  plugins: [
    //Other plugins...
    //You have to include this plugin before rfs
    require('postcss-rfs-autopilot')(),
    require('rfs')()
  ]
}

Now we will mark up all the values for you with rfs():rocket::rocket::rocket:!

If you want to include or exclude some values or selectors, you can pass a configuration object to this plugin like this:

Check out our API Reference for configuration options.

//postcss.config.js or other files you use to config PostCSS

module.exports = {
  plugins: [
    //Other plugins...
    //You have to include this plugin before rfs
    require('postcss-rfs-autopilot')({
      includedRules: [
        '*'
      ], //Rules you want to include, e.g. font-size
      includedSelectors: [
        'p #hello'
      ], //Selectors you want to include,
      includedUnits: [
        'px', 'rem'
      ], //Units you want to include, e.g. px.  Noted that RFS currently only works with px and rem
      excludedRules: [], //Rules you want to exclude
      excludedSelectors: [], //Selectors you want to exclude
      excludedUnits: [] //Units you want to exclude
      }),
    require('rfs')
  ]
}

Examples

Apply rfs() to all values, selector, and rules except width and height:

module.exports = {
  plugins: [
    //Other plugins...
    require('postcss-rfs-autopilot')({
      excludedRules: ['width', 'height']
    }),
    require('rfs')
  ]
}

Apply rfs() to class foo and bar only:

module.exports = {
  plugins: [
    //Other plugins...
    require('postcss-rfs-autopilot')({
      includedSelectors: ['.foo', '.bar']
    }),
    require('rfs')
  ]
}

Advanced

Exclusion rules will have precedence over inclusion rules, which means that if a same rules is found in both includedRules and excludedRules, it will be excluded.

If you want to include all for an option, pass in "*" as its value.

API Reference

options.includedRules

Data type: [Array]

Default value: [ '*' ]

Description: Control which CSS rules you want this plugin wrap it up with rfs(), for example font-size

options.includedSelectors

Data type: [Array]

Default value: [ '*' ]

Description: Control which CSS selectors you want this plugin wrap it up with rfs(), for example p .free

options.includedUnits

Data type: [Array]

Default value: [ 'px', 'rem' ]

Description: Control which CSS units you want this plugin wrap it up with rfs(), for example px

options.excludedRules

Data type: [Array]

Default value: []

Description: Control which CSS rules you do not want this plugin wrap it up with rfs(), for example font-size

options.includedSelectors

Data type: [Array]

Default value: []

Description: Control which CSS selectors you do not want this plugin wrap it up with rfs(), for example p .free

options.includedUnits

Data type: [Array]

Default value: []

Description: Control which CSS units you do not want this plugin wrap it up with rfs(), for example px

options.silentConsole

Data type: [Boolean]

Default value: false

Description: Set it true to suppress all logs in console.