huituanxueqian 7740728225 commit | 1 gadu atpakaļ | |
---|---|---|
.. | ||
lib | 1 gadu atpakaļ | |
node_modules | 1 gadu atpakaļ | |
LICENSE | 1 gadu atpakaļ | |
README.md | 1 gadu atpakaļ | |
changelog.md | 1 gadu atpakaļ | |
hookRequire.js | 1 gadu atpakaļ | |
index.js | 1 gadu atpakaļ | |
package.json | 1 gadu atpakaļ |
Allow postcss to support inline comments.
npm i --save-dev postcss postcss-comment
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)
})
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)
})
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 */