Detalhes do pacote

postcss-prettify

codekirei9.2kMIT0.3.4

prettify postcss output

postcss-plugin, prettify

readme (leia-me)

postcss-prettify version build coverage

About | Installation | Usage | License


About

A PostCSS plugin to prettify output. Requires at least Node.js v0.12. Should likely be included towards the end of a PostCSS plugin chain, if that's your jam.

Features

  • line breaks between top-level rules and comments
  • smart spacing around rules and declarations
  • indenting with 2 spaces
  • one selector per line

Example Input

.foo, .bar {
    background: red;
}
@media only screen and (min-width:600px){.baz{background:blue;}}

Example Output

.foo,
.bar {
  background: red;
}

@media only screen and (min-width: 600px) {
  .baz {
    background: blue;
  }
}

Installation

From a terminal

npm install --save-dev postcss-prettify

Usage

As a PostCSS Plugin

postcss([
  require('postcss-prettify')
])

Check the PostCSS docs for your chosen implementation.

Standalone

postcss-prettify also exposes a standalone PostCSS processor instance as prettify.process(css):

var fs = require('mz/fs')
var prettify = require('postcss-prettify')

fs.readFile('src/style.css', 'utf8')
  .then(data => prettify.process(data))
  .then(res => fs.writeFile('dist/style.css', res.css))
  .catch(err => console.err(err.stack))

License

MIT

changelog (log de mudanças)

Change Log

This project uses semver.

0.3.4 — 3/16/16

Fix fail on empty input with checks for setting css.first.raws.before = ''.

0.3.1 - 0.3.3 — 3/16/16

  • Update readme and changelog.
  • Fix "files" field not being an array.
  • Fix /dist not being included with package by adding /dist to "files" in package.json.

0.3.0 — 3/16/16

Switch codebase to es6 with Babel transpilation. Optimize logic into one tree traversal.

ADD

  • smart spacing and indentation around rules and declarations
  • only target top-level rules and comment for enforced empty linebreak

0.2.0 — 3/11/16

Restructure logic for easy extending.

ADD

  • prepend newline to @rules (previously only affected non-@rules)

0.1.1 — 3/10/16

Switch from AVA to Mocha for tests because Travis-CI was throwing strange errors I don't feel like tracking down.

0.1.0 — 3/10/16

Initial release.

ADD

  • newlines between rules
  • one selector per line