我正在获取文件并使用gulp移动它:
gulp.src('src/myfile.html')
.pipe(gulp.dest('dist'));
如何重命名文件?
答案 0 :(得分:1)
尝试https://www.npmjs.com/package/gulp-rename
// rename via string
gulp.src("./src/main/text/hello.txt")
.pipe(rename("main/text/ciao/goodbye.md"))
.pipe(gulp.dest("./dist")); // ./dist/main/text/ciao/goodbye.md
// rename via function
gulp.src("./src/**/hello.txt")
.pipe(rename(function (path) {
path.dirname += "/ciao";
path.basename += "-goodbye";
path.extname = ".md"
}))
.pipe(gulp.dest("./dist")); // ./dist/main/text/ciao/hello-goodbye.md