在线时间:8:00-16:00
迪恩网络APP
随时随地掌握行业动态
扫描二维码
关注迪恩网络微信公众号
开源软件名称(OpenSource Name):wpfpizicai/gulp-md5-plus开源软件地址(OpenSource Url):https://github.com/wpfpizicai/gulp-md5-plus开源编程语言(OpenSource Language):JavaScript 100.0%开源软件介绍(OpenSource Introduction):gulp-md5-plus
UsageFirst, install npm install --save-dev gulp-md5-plus Then, add it to your var md5 = require("gulp-md5-plus");
gulp.src("./src/*.css")
.pipe(md5(10,'./output/index.html'))
.pipe(gulp.dest("./dist")); md5 all css files in the src folder and change these css names in the quoted html--index.html gulp.task('img' ,function() {
var imgSrc = './static/img/**',
quoteSrc = './output/static/css/**/*.css', // [./output/static/css/**/*.css',./output/static/js/**/*.js']
imgDst = './output/static/img';
return gulp.src(imgSrc)
.pipe(imagemin())
.pipe(md5(10 ,quoteSrc))
.pipe(gulp.dest(imgDst));
}); first, optimize all images in the img folder including all sub folders; then md5 all these images and change these images' names in the quoted css files ; ####note the directory of the md5ed files in the imgDst folder is the same as that of original files in the imgSrc folder; and css files can refer the image file with the same name in different folder rightly; APImd5(size,file,option)sizeType: Default: null
fileType: Default: null
optionType: Default: null option.dirLevelType: Default: null
Example: gulp.task('img' , ['css'],function() {
gulp.src('./source/img/**/*')
.pipe(md5(10 ,'./output/css/*.css',{
dirLevel : 1,
mappingFile: 'manifest.json',
connector: '.'
}))
.pipe(gulp.dest('./output/img/'));
}); The sample above will append the md5 hash(length : 10) to each of the file in the static/js folder then repalce the link file name in the output/html/ using md5ed file name; at last store all of that into the output folder. option.connectorType: Default:
option.mappingFileType: Default: null
after set this option ;you should remove this file before DemoI have add a demo to demonstate how to use this plugin; If you have any other questions ,pls add issues. Licensehttp://en.wikipedia.org/wiki/MIT_License[MIT License] |
2023-10-27
2022-08-15
2022-08-17
2022-09-23
2022-08-13
请发表评论