我试图使src路径动态并且它工作但它以某种方式弄乱了目标
var gulp = require('gulp');
var sass = require ('gulp-sass');
var sassUrl = '**/style.scss';
// compile sass
gulp.task('compile-sass', function(){
gulp.src([sassUrl])
.pipe(sass())
.pipe(gulp.dest('dist/css'))
});
在这个例子中
答案 0 :(得分:1)
我迟到但我想你想研究为你的src设置你的基础(这将影响最终位置)。有关详细信息,请参阅https://gulpjs.org/api#gulpdestpath-options,但这里有一个快速的代码段,可以帮助您:
gulp.src('client/js/**/*.js') // Matches 'client/js/somedir/somefile.js' and resolves `base` to `client/js/`
.pipe(minify())
.pipe(gulp.dest('build')); // Writes 'build/somedir/somefile.js'
gulp.src('client/js/**/*.js', { base: 'client' })
.pipe(minify())
.pipe(gulp.dest('build')); // Writes 'build/js/somedir/somefile.js'