Important: This documentation covers Yarn 1 (Classic).
For Yarn 2+ docs and migration guide, see yarnpkg.com.

Package detail

postcss-comment

zoubin55.9kMIT2.0.0

Allow postcss to support inline comments

postcss, inline, comment

readme

postcss-comment

version status dependencies devDependencies

Allow postcss to support inline comments.

Usage

npm i --save-dev postcss postcss-comment

As parser

var postcss = require('postcss')
var parser = require('postcss-comment')

var fs = require('fs')

var file = __dirname + '/inline.css'

postcss()
  .process(
    fs.readFileSync(file, 'utf8'),
    { from: file, parser: parser }
  )
  .then(function (result) {
    console.log(result.css)
  })

Hook require

require('postcss-comment/hookRequire')
var postcss = require('postcss')

var fs = require('fs')

var file = __dirname + '/inline.css'

postcss()
  .process(
    fs.readFileSync(file, 'utf8'),
    { from: file }
  )
  .then(function (result) {
    console.log(result.css)
  })

Or:

var postcss = require('postcss-comment/hookRequire')

var fs = require('fs')

var file = __dirname + '/inline.css'

postcss()
  .process(
    fs.readFileSync(file, 'utf8'),
    { from: file }
  )
  .then(function (result) {
    console.log(result.css)
  })

Example

inline.css:

/*
 * comments//
 * //comments
 */
// comments
//* comments*/
.inline-comment { /// comments
  // com//ments
  color: red; // comments
} // /*comments
//*/ comments

outputs:

/*
 * comments//
 * //comments
 */
/* comments */
/** comments*\/ */
.inline-comment { /*\/ comments */
  /* com//ments */
  color: red; /* comments */
} /* /*comments */
/**\/ comments */

changelog

v1.0.3 (2016-01-27)

v1.0.2 (2015-11-19)

v1.0.1 (2015-11-19)

v1.0.0 (2015-11-19)

  • [ffd8348] Support both the hooRequire way and the parser way

v0.1.2 (2015-11-05)

v0.1.1 (2015-11-04)

  • [ce85730] update readme for usage

v0.1.0 (2015-11-04)

  • [b1c4209] hack postcss to support inline comments

  • [7103b6a] Initial commit