PostCss: by @solodynamo

PostCss = CSS parser + AST tree + Plugins + Plugins ...+ ..+ Plugins + Stringifier

  1. Quite Heavy Words!! Lets go step by step

CSS parser & AST tree

  1. This results into...
  1. An Abstract Syntax Tree
  1. Plugins can now manipulate the nodes.
  2. At last Stringifier converts back to css.

Why i need postcss?

  1. Normal CSS or only SASS wont work?

Advantages

1. Solve Global CSS Problem

  1. In Sass, we give our classes definite scope by nesting them!

Even Sass has tradeoffs !

  1. Specificity is a bad thing and forces the innocent devs to use..
  2. !important
  3. ID's rather than Classes

2. Use Future CSS, Today

  1. Courtesy of cssnext plugin for postcss.

3. Avoid errors in your CSS

  1. Courtesy of css stylelint plugin for postcss.

Conclusion from 'n-1' slides

With PostCss its all about my usecase i.e.

  1. Will be including features i require in my project through plugins thus following a modular approach.
  2. Not like SASS in which for just using mixins i would have to get all its features like @extend etc.

Some Rockstar Plugins

Autoprefixer

  1. PostCSS plugin to parse CSS and add vendor prefixes to CSS rules using values from Can I Use

css-loader

  1. Uses css-modules internally.
  2. Will see next what problem it solves.

Problem !

  1. it's hard to tell if they are will be red or blue (it's hard to predict order of styles created by style-loader)

Solution !

  1. Replaces every local-scoped identifier with a global unique name.

extract-text-webpack-plugin

  1. Your styles are no longer inlined into the JS bundle.
  2. Caveats : Additonal HTTP requests.

postcss-cssnext

  1. PostCSS-cssnext is a PostCSS plugin that helps you to use the latest CSS syntax today.
  2. So you don’t need to wait for browser support.
  3. Some features....

postcss-cssnext:Features

Features : cont.....
Features : cont.....
Features : cont.....
Code Time
  1. PostCss With Webpack 2 setup along with React

Questions

Sayonara