2015-10-06 53 views
7

我試圖編譯sass使用gulp-ruby-sass但我得到TypeError: glob pattern string requiredTypeError:需要的模式字符串

這是我gulpfile.js是什麼樣子:

var gulp = require('gulp'), 
    sass = require('gulp-ruby-sass'); 

var paths = { 
    sassSrcPath: ['Content/css/**/*.scss'], 
    sassDestPath: ['build/css/'], 
    sassImportsPath: ['Content/styleguide/'] 
}; 

// Styles Task 
gulp.task('styles', function() { 
    gulp.src(paths.sassSrcPath) 
     .pipe(sass({ 
      style: 'compressed', 
      loadPath: [paths.sassImportsPath] 
     })) 
     .pipe(gulp.dest(paths.sassDestPath)); 
}); 

// Watch Task 
gulp.task('watch', function() { 
    gulp.watch(paths.sassSrcPath, ['styles']); 
}); 

gulp.task('default', ['styles', 'watch']); 

這裏是我的文件夾結構:

├── Content 
│ ├── css 
│ │ ├── partials 
│ │ │ └─_icons.scss 
│ │ ├── main.css.scss 
│ │ └── styleguide.css.scss 
│ └── styleguide 
│  ├── css 
│  │ └─ vendor 
│  │  └─ // Bunch of other folders that contain .sass files 
│  └── // Other .sass files 
└── gulpfile.js 

我全新吞掉,我沒有使用任何步兵所以原諒我如果我犯了一個微不足道的錯誤。

+0

甚至直接運行後,上海社會科學院,這也sassDestPath:['build/css /']生成錯誤「錯誤:無效的輸出文件夾」,所以我將其更改爲'build/css /',這就解決了問題 –

回答

14

望着docs,它似乎並不像你應該管到gulp-ruby-sass,而是直接調用它像:

gulp.task('styles', function() { 
    return sass(paths.sassSrcPath, { 
      style: 'compressed', 
      loadPath: [paths.sassImportsPath] 
     }) 
     .pipe(gulp.dest(paths.sassDestPath)); 
}); 
在我的情況
+1

非常感謝,我觀看了視頻教程gulp-ruby- sass被用於我使用它的方式,所以我甚至沒有看官方文檔。 – msmolcic

相關問題