Gulp任务复制目录中的所有文件,编译所有SCSS文件,保持其他文件不变?
问题描述:
我有一个scss
目录里面一堆文件:Gulp任务复制目录中的所有文件,编译所有SCSS文件,保持其他文件不变?
scss/
file.scss
anotherfile.scss
image.jpeg
dir/
other.ttf
我想gulp
编译这:
css/
file.css
anotherfile.css
image.jpeg
dir/
other.ttf
目前,它编译所有.css
文件,但它不会对任何复制的其他文件。
这就是我现在有;
const path2 = require('path');
...
gulp.task('sass', function() {
gulp.src("./scss/*.scss")
.pipe(sass({outputStyle: 'compressed'}))
.on('error', onError)
.pipe(rename (function (path) {
path.dirname = path.dirname.replace(path2.sep + "scss", path2.sep + "css");
path.extname = ".css";
}))
.pipe(gulp.dest('./'));
});
我该怎么做?
谢谢。
答
gulp.task('sass', function() {
gulp.src("scss/*.scss")
.pipe(sass({outputStyle: 'compressed'}))
.on('error', onError)
.pipe(gulp.dest('css/'));
// copy everything except *.scss & *.sass
gulp.src([
"scss/**/*",
"!scss/**/*.{sass,scss}"
])
.pipe(gulp.dest('css/'));
});