postcss-comment-2
v1.0.1
Published
Allow postcss to support inline comments. Works with PostCSS 6
Downloads
377
Maintainers
Readme
postcss-comment-2
Allow postcss to support inline comments. Updated to work with PostCSS 6.
Usage
npm i --save-dev postcss postcss-comment-2
Webpack postcss.config.js
module.exports = {
parser: 'postcss-comment-2',
plugins: {
// ... other plugins
},
}
As parser
var postcss = require('postcss')
var parser = require('postcss-comment-2')
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-2/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-2/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 */