在 Gulp 中将输出 directories/files 更改为小写
Changing output directories/files to lowercase in Gulp
我正在使用 Gulp 自动 copy/bundle/compile 我的文件,我基本上将整个文件夹结构从基本文件夹 (MyProject/Scripts) 复制到 wwwroot/js。
在 copying/processing 的过程中,我想将输出 path/filenames 重命名为小写。我找到了 ChangeCase 模块和 Rename 模块,但我无法在下面的设置中使用它。
gulp.task("compile:less", function () {
return gulp.src(paths.lessSrc)
.pipe(less())
//how can I get to currentdirectory so I can use it for the rename? maybe there is another way
//.pipe(rename({ dirname: changeCase.lowerCase(??currentdir??) }))
.pipe(gulp.dest(paths.cssTarget));
});
和
gulp.task("compile:js", function () {
return gulp.src(paths.jsOrigin)
//simple copy of folders and files but how to rename all to lowercase?
.pipe(gulp.dest(paths.jsTarget));
});
您可以将回调函数传递给 gulp-rename
:
gulp.task("compile:js", function () {
return gulp.src(paths.jsOrigin)
.pipe(rename(function(path) {
path.dirname = changeCase.lowerCase(path.dirname);
path.basename = changeCase.lowerCase(path.basename);
path.extname = changeCase.lowerCase(path.extname);
}))
.pipe(gulp.dest(paths.jsTarget));
});
我正在使用 Gulp 自动 copy/bundle/compile 我的文件,我基本上将整个文件夹结构从基本文件夹 (MyProject/Scripts) 复制到 wwwroot/js。
在 copying/processing 的过程中,我想将输出 path/filenames 重命名为小写。我找到了 ChangeCase 模块和 Rename 模块,但我无法在下面的设置中使用它。
gulp.task("compile:less", function () {
return gulp.src(paths.lessSrc)
.pipe(less())
//how can I get to currentdirectory so I can use it for the rename? maybe there is another way
//.pipe(rename({ dirname: changeCase.lowerCase(??currentdir??) }))
.pipe(gulp.dest(paths.cssTarget));
});
和
gulp.task("compile:js", function () {
return gulp.src(paths.jsOrigin)
//simple copy of folders and files but how to rename all to lowercase?
.pipe(gulp.dest(paths.jsTarget));
});
您可以将回调函数传递给 gulp-rename
:
gulp.task("compile:js", function () {
return gulp.src(paths.jsOrigin)
.pipe(rename(function(path) {
path.dirname = changeCase.lowerCase(path.dirname);
path.basename = changeCase.lowerCase(path.basename);
path.extname = changeCase.lowerCase(path.extname);
}))
.pipe(gulp.dest(paths.jsTarget));
});