我尝试运行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"
}
我进行了一些搜索,但仍未找到问题所在。
提前致谢。
答案 0 :(得分:1)
我今晚也遇到了这个问题。我通过更改config.rb路径来修复它。尝试
.pipe(compass({
config_file: './config.rb',
css: paths.css,
sass: paths.sass
}))
如果你没有/想要使用config.rb,我相信你必须像在"加载配置而不是config.rb"中那样设置项目根目录。 https://www.npmjs.org/package/gulp-compass
的部分答案 1 :(得分:1)
我用这个来编译我的指南针文件,它运行正常,它来自gulp-compass docs
如果你没有使用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'));
});
答案 2 :(得分:0)
我也遇到了这个问题,我发现项目路径需要指向包含css,scss文件夹的文件夹。例如:
app /
- src /
- css /
- sass /
鉴于上述结构,您的配置应如下所示:
project: "app/src",
css: "css",
sass: "sass"
当我的项目路径高一级时,我收到错误,使我的css属性看起来像:"src/css"