解釋?zhuān)和ㄟ^(guò)gulp.dest是不能生成想要的目錄結(jié)構(gòu)的逆甜,必須修改下路徑(gulp-rename)才行
//目錄結(jié)構(gòu)
content/hybrid/styles/
+-- /product
| +- /sass
| | +- a.scss
| +- a.css
|
+-- /magic
+- /sass
| +- b.scss
+- b.css
var rename = require('gulp-rename'),
sass = require('gulp-sass'),
gulp.task('sassCompile', function () {
return gulp.src('content/hybrid/styles/**/sass/*.scss')
.pipe(sass())
.pipe(rename(function (path) {
for (var key of Object.keys(path)) {
// mac路徑
path[key] = path[key].replace(/\/sass/g, '');
// window路徑
path[key] = path[key].replace(/\\sass/g, '');
}
}))
.pipe(gulp.dest('content/hybrid/styles/'));
});