PostCSS cli 在解释 sourcemap 时遇到来自标准输入的最大行长度

PostCSS cli encountering max line length from stdin when interpreting sourcemap

我的 package.json 中有如下 sass 编译设置:

"scripts": {
    "sass": "node-sass sass/app.scss --source-map-root file://${PWD}/ --source-map-embed true",
    "postcss:autoprefixer": "postcss --use autoprefixer -b 'last 2 versions' --map",
    "css": "npm run sass -s | npm run postcss:autoprefixer -s | exorcist css/app.css.map > css/app.css"
  }

创建外部资源映射 运行 一段时间以来一直很好。但是最近它一直失败,postcss 抛出未关闭的评论错误。有问题的评论是 sourceMappingURL 的开始标记。 sourceMappingURL 被 node-sass 作为 dataUri 使用 --source-map-embed true 命令嵌入,这是源映射使用此方法工作所必需的,因为它似乎 node-sass 赢了' 如果将输出通过管道输出到标准输出,则将它们写入文件。

我猜 dataUri 太长了,它达到了某种最大行长度。这个限制是在 bash(我在 Mac OSX),node.js 还是 postcss-cli 我不确定?它是我可以手动增加的东西,还是有任何其他解决方法?

更新: 经过进一步研究,问题似乎源于 read-file-stdin which is returning an incomplete file from process.stdin. I'm not too familiar with node streams, but read-file-stdin relies on stream.pipe to read the data and I believe uses gather-stream 将流块收集在一起。但是,这是行不通的。如果我将 css 脚本更改为以下内容:npm run sass -s | test.js 其中 test.js 如下:

#!/usr/bin/env node
const gather = require( 'gather-stream' );

process.stdin.pipe( gather( complete ) );

function complete ( err, data ) {
    console.log( data.toString( 'utf8' ) );
}

控制台输出是一个不完整的文件

这实际上是 node-sass 的错误,即 now fixed