标签:文件名 += 项目 tin base 查看 UNC you dirname
//在js中导入nodo中的包的时候,需要使用到一个函数require()
//只需要将所需要导入的包传递给require()函数就可以了
var gulp =require('gulp');
var cssnano = require('gulp-cssnano');
var rename = require('gulp-rename');
gulp.task('css', function() {
gulp.src('./css/*.css')
.pipe(cssnano())
//这个命令规则就是在经过压缩过后的文件候命加上一个后缀为min
.pipe(rename({
'suffix':'.min'
}))
.pipe(gulp.dest('./dist/css/'))
});
var rename = require("gulp-rename");
// rename to a fixed value
gulp.src("./src/main/text/hello.txt")
//rename the filename
.pipe(rename("main/text/ciao/goodbye.md"))
//the destination
.pipe(gulp.dest("./dist")); // ./dist/main/text/ciao/goodbye.md
// rename via mutating function
gulp.src("./src/**/hello.txt")
.pipe(rename(function (path) {
// Updates the object in-place
path.dirname += "/ciao";
path.basename += "-goodbye";
path.extname = ".md";
}))
.pipe(gulp.dest("./dist")); // ./dist/main/text/ciao/hello-goodbye.md
// rename via a map function
gulp.src("./src/**/hello.txt")
.pipe(rename(function (path) {
// Returns a completely new object, make sure you return all keys needed!
return {
dirname: path.dirname + "/ciao",
basename: path.basename + "-goodbye",
extname: ".md"
};
}))
.pipe(gulp.dest("./dist")); // ./dist/main/text/ciao/hello-goodbye.md
// rename via a fixed object
gulp.src("./src/main/text/hello.txt", { base: process.cwd() })
.pipe(rename({
dirname: "main/text/ciao",
basename: "aloha",
prefix: "bonjour-",
suffix: "-hola",
extname: ".md"
}))
.pipe(gulp.dest("./dist")); // ./dist/main/text/ciao/bonjour-aloha-hola.md
标签:文件名 += 项目 tin base 查看 UNC you dirname
原文地址:https://www.cnblogs.com/guyan-2020/p/12387337.html