问题描述
我无法让 grunt-sass 编译为 .css.看过很多其他类似的帖子并使用了建议,但似乎没有任何效果.
I'm not able to get grunt-sass to compile to .css. Have seen a load of other similar posts and utilized suggestions but nothing seems to work.
我可以让其他插件正常工作(例如'del'删除内容,显示在这里)所以看起来我的环境没问题,我可以让普通的 vanilla sass 编译/监视正常工作.
I can get other plugins working fine (for example 'del' to delete stuff, shown here) so it seems my environment is ok, and i can get ordinary vanilla sass compile/watch to work fine.
这是我的设置以防万一:
Here's my setup just in case:
OSX Maverics 10.9.5
OSX Maverics 10.9.5
$ ruby -v
ruby 2.0.0p481 (2014-05-08 revision 45883) [universal.x86_64-darwin13]
$ sass -v
Sass 3.4.9 (Selective Steve)
$ npm -v
2.1.12
$ brew -v
Homebrew 0.9.5
项目目录结构如下:
├── index.html
│
├── scss
│ └── base.scss
│ ├── _partial1.scss
│ └── _partial2.scss
│
├── assets
│ └── css
│ └── Nothing yet!
│
├── deltest
│ └── save.txt
│
├── gulpfile.js
│
└── node_modules
└── etc ...
这是我的 gulpfile.js:
Here's my gulpfile.js:
var gulp = require('gulp');
var sass = require('gulp-sass');
var del = require('del');
gulp.task('gsas', function() {
gulp.src('./scss/base.scss')
.pipe(sass({ includePaths : ['./scss/'] }))
.pipe(gulp.dest('./assets/css'))
});
del(['!deltest/save.txt', 'deltest/delete.txt'], function (err, deletedFiles) {
console.log('Files deleted:', deletedFiles.join(', '));
});
gulp.task('default', function() {
console.log('AAAAAAAAAAAAAAAARGH!');
});
谁能看出这里出了什么问题?
Can anyone see what is wrong here?
已更新 - 相同的任务在 windows 框中静默失败:
这是来自 windows box 测试的 gulpfile.js,我什至没有 @importing 任何部分(目录结构 完全是,如任务设置中所示,我直接从实际中提取插件示例):
Here's the gulpfile.js from the windows box test and I'm not even @importing any partials (the dir structure is exactly as shown in the task setup, which i pulled straight from the actual plugin example):
var gulp = require('gulp');
var sass = require('gulp-sass');
var del = require('del');
gulp.task('sass', function () {
gulp.src('./scss/*.scss')
.pipe(sass())
.pipe(gulp.dest('./css'));
});
del(['delete/delete.txt', '!delete/save.txt'], function (err, deletedFiles) {
console.log('Files deleted:', deletedFiles.join(', '));
});
gulp.task('default', function () {
console.log("Made it!");
});
在这个示例中,我再次让del"任务运行良好,但 gulp-sass 默默地失败了,这真的令人困惑.
In this example again I'm getting the 'del' task to run fine but gulp-sass fails silently and it's really baffling.
推荐答案
如果你希望 sass
任务在你从命令行运行 gulp
时执行,添加它作为 default
任务的依赖项:
If you want the sass
task to execute when you run gulp
from the command-line, add it as a dependency of the default
task:
gulp.task('default', ['sass'], function() {
//other stuff
});
这篇关于Gulp-sass 不会编译成 CSS的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!