如何将sass --watch的输出管道输出到autoprefixer?

pen*_*ton 8 sass command-line-interface autoprefixer

我有一个像我这样的Sass样式的构建命令:

sass src/styles/main.scss --style compressed | autoprefixer -b \"> 1%, IE 8\" > dist/main.css

现在,我想对开发过程有类似的命令.但我无法弄清楚如何将更改的文件sass --watch传输到autoprefixer cli.我设法用OSS的fswatch工具解决它,但我希望能有一个更简单,更通用的解决方案

小智 0

你检查过gulp吗?gulp-sass使用和gulp-autoprefixer节点包做你想做的事情真的很容易。

你的类似这样的东西gulpfile.js

var gulp         = require('gulp');
var sass         = require('gulp-sass');
var autoprefixer = require('gulp-autoprefixer');

gulp.task('scss', function() {
    return gulp.src('path/to/styles.scss')
    .pipe(sass())
    .pipe(autoprefixer())
    .pipe(gulp.dest('path/to/css'))
});
Run Code Online (Sandbox Code Playgroud)