在Gulp中将输出目录/文件更改为小写
问题描述:
我使用Gulp自动复制/捆绑/编译我的文件,我基本上将整个文件夹结构从基础文件夹(MyProject/Scripts)复制到wwwroot/js。在Gulp中将输出目录/文件更改为小写
在复制/处理过程中,我想将输出路径/文件名重命名为小写。我发现ChangeCase模块和重命名模块,但我无法让它在我的设置下面工作。
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));
});
+0
这工作:)谢谢 – user2713516
你尝试只是把那种语法:目录名称:changeCase.lowerCase()?所以你只需使用函数进行dirname重命名。 – Prototype
还没有尝试,但回答下面工作:)谢谢 – user2713516