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-fn

v0.1.7

Published

PostCSS to CSS parser

Downloads

4

Readme

Build Status Codecov Dependency Status

PostCSS-Fn

Generate css file out of PostCSS file

It can be used only with --harmony-async-await flag turned on (Node.js versions above 7.0.0)

Argumentation

With so many Postcss plugins, it is not a surprise to see libraries, that bundles several plugins altogether.

Such libraries are CSSNext and Rucksack.

PostCSS-Fn in comparision to CSSNext is not a PostCSS plugin, rather that a ready to use PostCSS** parser with predefined plugins.

PostCSS-Fn also could lift some weight from your Webpack configuration, so it doesn't reminiscent rocket science project.

Plugins used

  • autoprefixer
  • cssnano
  • postcss
  • postcss-calc
  • postcss-discard-empty
  • postcss-if-media
  • postcss-inherit
  • postcss-nested-props
  • postcss-nesting
  • postcss-partial-import(fork)
  • precss
  • rucksack-css
  • stylefmt

Simple Usage

const postCssFn = require("postcss-fn")
const filepath = "testCss.pcss"
const output = "testCss.css"

postCssFn( filepath, output, { cssnano: false } )
.then( result => {
  const fileContent = fs.readFileSync(output, "utf8")
  console.log(fileContent.trim() === result.trim()) // => true
})

Install

npm i postcss-fn

API

postCssFn(source,[output],[options])

  • source - full path to the .pcss file
  • output - full path to the output css file

If omited, output will be equal to the source with .css instead of .pcss extension

  • options - object of options

Default options:

{
    autoprefixer: "last 2 versions",
    rucksack: {
        fallbacks: true
    },
    stylelint: true,
    cssnano: true
}

You overwrite those options with the object you pass in. So if you pass {autoprefixer: "last 4 versions", cssnano:false} the options will become:

{
    autoprefixer: "last 4 versions",
    rucksack: {
        fallbacks: true
    },
    stylelint: true,
    cssnano: false
}

The stylelint options formats the source .postcss file with predefined options.

Example Input

// importing rules from ./files/_colors.css
@import "./files/colors";

$zIndex:100;
$width: 100px;
$fontSize: 10vh;
$viewport: 480px;

.foo {

	&__bar {
    font-size: calc(4 * $fontSize) ?if media (max-width: $viewport);
    border: 1px solid var(--blue);
    z-index:$zIndex;
		height: 70vh;
		width: (1.333*70vh);
    background-image: linear-gradient(to bottom, var(--navy), var(--bluegreen-seventh));
	}

	&__baz {
		@inherit: .foo__bar ;
    position: absolute;
    top: 1vw;
    right: 1vmin;
    font: {
      size: 30em;
      weight: bold;
    }
    z-index:calc($zIndex+100);
    animation: barbaz 1s;
	}
}

@keyframes barbaz {
	0% {
		background-color: var(--navy);
	}

	100% {
		background-color: var(--bluegreen-seventh);
	}
}

Output for the above Example

.foo__bar, .foo__baz {

	border:1px solid #5d9cec;

	z-index:100;

	height:70vh;

	width:(1.333*70vh);

	background-image:linear-gradient(to bottom, #3f7063, #2e6e65);
}

@media (max-width: 480px) {

	.foo__bar, .foo__baz {

		font-size:40vh;
	}
}

.foo__baz {

	position:absolute;

	top:1vw;

	right:1vm;

	right:1vmin;

	font-size:30em;

	font-weight:bold;

	z-index:200;

	animation:barbaz 1s;
}

@keyframes barbaz {
	0% {
		background-color:#3f7063;
	}

	100% {
		background-color:#2e6e65;
	}
}