compass-sass – 与gulp-compass的Gulp错误:您必须从项目目录中编译单个样式表

前端之家收集整理的这篇文章主要介绍了compass-sass – 与gulp-compass的Gulp错误:您必须从项目目录中编译单个样式表前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。
我尝试运行gulp任务来编译我的sass项目但是因为我创建子文件夹app / assets /并将我的源文件放入其中,所以我有一个问题.之前当sass和css文件夹与我的gulpfile在同一目录中时,它运行得很好.如果我在我的基本目录上运行指南针监视命令我没有问题,这只是gulp-compass.

输出

Devnco: /Users/Devnco/Web/maquette ->gulp sass
[gulp] Using gulpfile ~/Web/maquette/gulpfile.js
[gulp] Starting 'sass'...
[gulp] Finished 'sass' after 6.12 ms
[gulp] You must compile individual stylesheets from the project directory.
[gulp] Plumber found unhandled error: [gulp] Error in plugin 'gulp-compass': Compass Failed
[gulp] You must compile individual stylesheets from the project directory.
[gulp] Plumber found unhandled error: [gulp] Error in plugin 'gulp-compass': Compass Failed
[gulp] You must compile individual stylesheets from the project directory.
[gulp] Plumber found unhandled error: [gulp] Error in plugin 'gulp-compass': Compass Failed

我的gulpfile.js:

var paths = {
    css: './app/assets/css',sass: './app/assets/sass/*.scss',js: './app/assets/js',images: './app/assets/images'
}

gulp.task('sass',function(){

    gulp.src(paths.sass)
        .pipe(plumber())
        .pipe(compass({
            css: paths.css,sass: paths.sass
        }))
        .pipe(gulp.dest(paths.css))
        .pipe(minifyCss())
        .pipe(rename({ extname: '.min.css'}))
        .pipe(gulp.dest(paths.css));
});

我的工作目录:

gulpfile.js
app/
    assets/
        fonts/
        images/
        sass/
        css/
    pages/
        etc…

我的package.json与我使用的版本(最新)

"devDependencies": {
  "gulp": "^3.6.2","gulp-compass": "^1.1.9","gulp-concat": "^2.2.0","gulp-minify-css": "^0.3.4","gulp-plumber": "^0.6.2","gulp-rename": "^1.2.0"
}

我做了一些搜索,但仍未找到问题所在.

提前致谢.

解决方法

我使用它来编译我的指南针文件,它工作正常,它来自gulp-compass文档

如果你没有使用config.rb

var compass = require('gulp-compass'),path = require('path');

gulp.task('compass',function() {
  gulp.src('./src/*.scss')
  .pipe(compass({
    project: path.join(__dirname,'assets'),css: 'css',sass: 'sass'
  }))
  .pipe(gulp.dest('app/assets/temp'));
});

如果你使用config.rb

var compass = require(‘gulp-compass’);

gulp.task('compass',function() {
  gulp.src('./src/*.scss')
  .pipe(compass({
    config_file: './config.rb',css: 'stylesheets',sass: 'sass'
  }))
  .pipe(gulp.dest('app/assets/temp'));
});

猜你在找的JavaScript相关文章