指南针行号注释不显示与Gulp [英] Compass Line Number Comments Not Showing Up with Gulp

查看:134
本文介绍了指南针行号注释不显示与Gulp的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图从GruntJS切换到Gulp,并遇到了一个问题,我的Gulp任务通过Compass处理我的SASS文件。文件编译只是罚款到单个CSS文件,因为他们在我的GruntJS实现,但我缺少行号注释,显示CSS的规则来自哪里
/ * line 26,../ _components / sass / _base.scss * /



我的gulpfile.js中的任务代码是:

  gulp.task('compass',function(){
gulp.src(sassSources)
.pipe(compass({
comment:
sass:'_components / sass',
image:'builds / dev / images',
style:'nested'
})
.on ',gutil.log))
.pipe(gulp.dest('builds / dev / css'))
});



$ b $ p <解决方案

注意 gulp-compass ,它不是一个gulp插件(虽然命名如此),并已被Gulp社区列入黑名单一会儿。它不是Gulp插件应该做的(例如,可以运行它们 gulp.src gulp.dest ),和其他插件已经在做它的工作完美。其中一个插件是 gulp-ruby-sass 。这项设定可能适用于您:

  var sass = require('gulp-ruby-sass'); 
gulp.task('compass',function(){
return sass(s​​assSources,{
compass:true,
lineNumbers:true
})。on 'error',gutil.log))
.pipe(gulp.dest('builds / dev / css'))
});

这使用 gulp-ruby-sass 可以使用 compass 扩展名运行。你看到我激活 lineNumbers 这里给你说输出。



我从你的Gulpfile看到,一些扩展需要一些 image ,我不知道究竟是什么,但如果它是强制的,你的设置,你可以更好地直接指挥罗盘(命令行工具)使用 require('child_process')。exec(...)


I am attempting to make the switch from GruntJS to Gulp and have run into a problem with my Gulp task for processing my SASS files via Compass. The files compile just fine into the single CSS file as they did under my GruntJS implementation, but I am missing the line number comments that show me where the CSS rules come from such as: /* line 26, ../_components/sass/_base.scss */

The code from my gulpfile.js for the task is:

gulp.task('compass', function() {
   gulp.src(sassSources)
     .pipe(compass({
        comments: true,
        sass: '_components/sass', 
        image: 'builds/dev/images',
        style: 'nested'
   })
   .on('error', gutil.log))
   .pipe(gulp.dest('builds/dev/css'))
});

Am I missing something?

解决方案

Be careful with gulp-compass, it is not a gulp plugin (albeit named so) and has been blacklisted by the Gulp community for quite a while. It does not what Gulp plugins are supposed to do (e.g. it's possible to run them without gulp.src and gulp.dest), and other plugins are already doing its work perfectly fine. One of those plugins is gulp-ruby-sass. This setup might work for you:

var sass = require('gulp-ruby-sass');
gulp.task('compass', function() {
   return sass(sassSources, {
     compass: true,
     lineNumbers: true
   }).on('error', gutil.log))
   .pipe(gulp.dest('builds/dev/css'))
});

This uses gulp-ruby-sass which is able to run with the compass extension. You see that I activated lineNumbers here to give you said output.

I see from your Gulpfile that you might have some extension requiring some images, I don't know exactly what that does, but if it's mandatory to your setup, you might better call compass directly (the command line tool) using require('child_process').exec(...)

这篇关于指南针行号注释不显示与Gulp的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆