Answer the question
In order to leave comments, you need to log in
How to dynamically change paths in gulp?
src/
a-module/
css/
js/
html/
sass/
ts/
jade/
b-module/
css/
js/
html/
sass/
ts/
jade/
Answer the question
In order to leave comments, you need to log in
If I'm not mistaken, it's enough just to specify a path like 'src/**/*.*'
Revised the question :) The gulp-rename
plugin does what you need. It is described in the documentation there: you can change the path specified in gulp.src on the fly (for example, replace sass with css).
For me it looked like this:
var gulp = require('gulp'),
sass = require('gulp-sass'),
rename = require('gulp-rename');
gulp.task('sass', function () {
gulp.src('./src/**/*.scss')
.pipe(sass({
includePaths: ['./src/']
}))
.pipe(rename(function(path){
// path.dirname = 'module-a(b)/sass' - это то, что задано в gulp.src
path.dirname = path.dirname.replace( "sass", "css" );
// path.dirname = 'module-a(b)/css' - а теперь мы поменяли так, как нам нужно
return path;
}))
.pipe(gulp.dest('./src/')); // и тогда все сложится в src/module-a(b)/css - в нужную папку модуля
});
gulp.task('default', ['sass']);
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question