/spike-css-standards

A rock solid plugin pack for postcss

Primary LanguageJavaScriptOtherNOASSERTION

Spike CSS Standards

npm tests dependencies coverage

standard plugin pack for postcss

Note: This project is in early development, and versioning is a little different. Read this for more details.

Installation

npm install spike-css-standards -S

Note: This project is compatible with node v6+ only

Usage

This is nothing more than a light wrapper around a postcss configuration object. Options are filtered into their appropriate plugins internally. All are optional.

const postcss = require('postcss')
const cssStandards = require('spike-css-standards')

const standards = cssStandards(/* options */)
// returns { parser: 'xxx', plugins: ['xxx'] }

postcss(standards.plugins)
  .process(someCss, { parser: standards.parser })
  .then((res) => { console.log(res.content) })

By default, the css standard plugin pack includes:

Any of these plugins can be customized by passing the options described below. You can also add additional postCSS plugins (like the popular lost grid, for example) on top of this package:

//  app.js
const cssStandards = require('spike-css-standards')
const lost = require('lost')

//  ...
postcss: (ctx) => {
  const css = cssStandards({ webpack: ctx })
  css.plugins.push(lost())
  return css
},
//  ...

Options

Name Description Default
root Root path used to resolve layouts and includes
addDependencyTo Object with addDependency method that will get file paths for tracked deps from includes/layouts
webpack Shortcut for webpack users to set the root and addDependencyTo options more easily. Pass webpack loader context.
browsers Browser support provided to autoprefixer > 1%, last 2 versions, Firefox ESR
features Enable or disable cssnext features
warnForDuplicates Enable or disable cssnext duplicate warnings true
rucksack Options passed directly to rucksack
parser custom css parser if desired. pass false to use the default css parser sugarss
minify Minifies the css output by removing excess spaces and line breaks false

License & Contributing