I am searching for a solution allowing to modify the base part of path. I have a path like 'app/assets/theme/file.css' that i get with 'app/**/*.css' pattern and I would like to transform it to 'dist/assets/theme/file.css'.
For now I am doing something like:
gulp.src(paths.styles)
.pipe(rename(function(path) {
path.dirname = paths.dist + path.dirname;
})
wich give me 'app/dist/assets/theme/file.css' instead of 'dist/assets/theme/file.css'. I don't find the way to erase 'app/' part.
How could I obtain the good result (using rename or another plugin if necessary) ?
There is a base
option in gulp.src
which you can use
gulp.src(paths.styles, {base: 'app'})
.pipe(gulp.dest('dist'));
Read the doc for more details.
您可以尝试使用String replace(),如下所示:
gulp.src(paths.styles) .pipe(rename(function(path) { var newPath = paths.dist + path.dirname; path.dirname = newPath.replace('app/'); })
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.