Neglected Pulse Machine

    postcss-comment

    2.0.0 • Public • Published

    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 */
     

    Install

    npm i postcss-comment

    DownloadsWeekly Downloads

    11,742

    Version

    2.0.0

    License

    MIT

    Unpacked Size

    18.3 kB

    Total Files

    9

    Last publish

    Collaborators

    • zoubin