这很奇怪。我有这个输出:
converting sass to css...
[18:36:00] gulp-debug: src/app/app.component.scss
[18:36:00] gulp-debug: src/app/pages/about/about.component.scss
[18:36:00] gulp-debug: src/app/pages/contact/contact.component.scss
[18:36:00] gulp-debug: src/app/pages/home/home.component.scss
[18:36:00] gulp-debug: src/app/pages/home/components/control-panel/control-panel.component.scss
[18:36:00] gulp-debug: 5 items
notify clients of css change
change /Users/alexamil/WebstormProjects/oresoftware/sumanjs/suman-chrome-extension/app/app.component.css
change /Users/alexamil/WebstormProjects/oresoftware/sumanjs/suman-chrome-extension/app/pages/home/home.component.css
change /Users/alexamil/WebstormProjects/oresoftware/sumanjs/suman-chrome-extension/app/pages/home/components/control-panel/control-panel.component.css
change /Users/alexamil/WebstormProjects/oresoftware/sumanjs/suman-chrome-extension/app/pages/about/about.component.css
change /Users/alexamil/WebstormProjects/oresoftware/sumanjs/suman-chrome-extension/app/pages/contact/contact.component.css
这是我的代码:
const gulp = require('gulp');
const gdebug = require('gulp-debug');
const sass = require('gulp-sass');
console.log('converting sass to css...');
gulp.src(path.resolve(root + '/src/**/**/*.scss'))
.pipe(gdebug())
.pipe(sass())
.pipe(gulp.dest('.'))
.once('finish', function () {
console.log('notify clients of css change');
notifyClients();
});
从日志中看,好像文件正在被写出,但是从我的编辑器中,文件系统中似乎没有任何新的.css文件,只有.scss文件。有人知道怎么了吗?
仅在动态src的情况下,并且您想要各自相同的dest(如src中所接收的那样,则可以使用以下代码]
示例假设我们有一个scss文件数组:
var gulp = require('gulp');
var sass = require('gulp-sass');
var scssArr = [
'src/asdf/test2.scss',
'src/qwerty/test1.scss'
];
function runSASS(cb) {
scssArr.forEach(function(p){
gulp.src(p, {base:'.'})
.pipe(sass({outputStyle: 'compressed'}))//outputStyle is optional or simply sass()
.pipe(gulp.dest('.')); //if othe folder including src path then use '/folder-name' instead of '.', so output path '/folder-name/{src-received-path}'
})
cb();
}
exports.runSASS = runSASS; // gulp runSASS
运行命令gulp runSASS
这将创建以下文件:
src / asdf / test2.css
src / qwerty / test1.css
快乐编码..