在线时间:8:00-16:00
迪恩网络APP
随时随地掌握行业动态
扫描二维码
关注迪恩网络微信公众号
开源软件名称(OpenSource Name):TheDancingCode/gulp-rev-rewrite开源软件地址(OpenSource Url):https://github.com/TheDancingCode/gulp-rev-rewrite开源编程语言(OpenSource Language):JavaScript 100.0%开源软件介绍(OpenSource Introduction):gulp-rev-rewrite
This plugin is an improved and maintained fork of gulp-rev-replace. Install
Only LTS and current releases of Node are supported. Usageconst { src, dest } = require('gulp');
const rev = require('gulp-rev');
const revRewrite = require('gulp-rev-rewrite');
function revision() {
return src('dist/**/*.{css,js}')
.pipe(rev())
.pipe(src('dist/**/*.html'))
.pipe(revRewrite())
.pipe(dest('dist'));
}
exports.default = revision; Alternatively:
const { readFileSync } = require('fs');
const { src, dest, series } = require('gulp');
const rev = require('gulp-rev');
const revRewrite = require('gulp-rev-rewrite');
// Step 1
function revision() {
return src('dist/assets/**/*.{css,js}')
.pipe(rev())
.pipe(dest('dist/assets'))
.pipe(rev.manifest())
.pipe(dest('dist/assets'));
}
// Step 2
function rewrite() {
const manifest = readFileSync('dist/assets/rev-manifest.json');
return src('dist/**/*.html')
.pipe(revRewrite({ manifest }))
.pipe(dest('dist'));
}
exports.default = series(revision, rewrite); APIrevRewrite([options])optionsType: manifestType: Read JSON manifests written out by prefixType: Add a prefix to each replacement. modifyUnreved, modifyRevedType: Modify the name of the unreved/reved files before using them. The function receives the unreved/reved filename as the first argument, and the Vinyl object of the current file as the optional second argument. LicenseMIT © James K Nelson, Thomas Vantuycom |
2023-10-27
2022-08-15
2022-08-17
2022-09-23
2022-08-13
请发表评论