Socket
Socket
Sign inDemoInstall

gulp-rev-rewrite

Package Overview
Dependencies
Maintainers
2
Versions
17
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

gulp-rev-rewrite

Rewrite references to assets that have been revisioned using gulp-rev


Version published
Weekly downloads
4.6K
decreased by-3.11%
Maintainers
2
Weekly downloads
 
Created
Source

gulp-rev-rewrite

Build Status npm semantic-release

Effortlessly rewrite references to revisioned assets by incorporating gulp-rev-rewrite into your revisioning workflow powered by gulp-rev.

Install

npm install gulp-rev-rewrite --save-dev

Usage

Option 1: Inline revisioning

In this approach, revisioning and rewriting are done in a single gulp task.

import gulp from 'gulp';
import rev from 'gulp-rev';
import revRewrite from 'gulp-rev-rewrite';

function revision() {
  return gulp.src('dist/**/*.{css,js}')
    .pipe(rev())
    .pipe(gulp.src('dist/**/*.html'))
    .pipe(revRewrite())
    .pipe(gulp.dest('dist'));
}

export default revision;

Option 2: Separate revisioning and rewriting

This approach separates asset revisioning from rewriting references to the revisioned assets.

import { readFileSync } from 'node:fs';
import gulp from 'gulp';
import rev from 'rev';
import revRewrite from 'gulp-rev-rewrite';

// Step 1: Asset revisioning
function revision() {
  return gulp.src('dist/assets/**/*.{css,js}')
    .pipe(rev())
    .pipe(gulp.dest('dist/assets'))
    .pipe(rev.manifest())
    .pipe(gulp.dest('dist/assets'));
}

// Step 2: Rewriting references
function rewrite() {
  const manifest = readFileSync('dist/assets/rev-manifest.json');

  return gulp.src('dist/**/*.html')
    .pipe(revRewrite({ manifest }))
    .pipe(gulp.dest('dist'));
}

export default gulp.series(revision, rewrite);

API

revRewrite([options])

options

Type: Object

manifest

Type: Buffer (e.g., fs.readFileSync())

Read JSON manifests generated by gulp-rev. This allows replacing filenames that were revisioned in a previous task.

License

MIT © Thomas Vantuycom

Keywords

FAQs

Package last updated on 28 Sep 2023

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc