# gulp-rev-rewrite

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

Latest version **7.0.0** (published 2026-07-16) · MIT license · 0 weekly downloads

## Install

```sh
npm install gulp-rev-rewrite
pnpm add gulp-rev-rewrite
yarn add gulp-rev-rewrite
bun add gulp-rev-rewrite
```

## Health

**Score 60/100 (C)** — status: active.

Positive: esm support; no vulnerabilities; has provenance; recently updated.

Warnings: low downloads; no types.

## Facts

| | |
|---|---|
| Version | 7.0.0 |
| Published | 2026-07-16 |
| First published | 2018-05-07 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | ESM |
| Node | >=24 |
| Dependencies | 1 |
| Unpacked size | 6.5 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Provenance | attested (GitHub Actions) |
| GitHub stars | 41 |
| Author | Thomas Vantuycom |
| Maintainers | thomasvantuycom |
| Keywords | asset, assets, gulpplugin, replace, rev, revision, revving, rewrite, version, versioning |

## Links

- npm: https://www.npmjs.com/package/gulp-rev-rewrite
- Repository: https://github.com/thomasvantuycom/gulp-rev-rewrite
- Homepage: https://github.com/thomasvantuycom/gulp-rev-rewrite#readme
- Issues: https://github.com/thomasvantuycom/gulp-rev-rewrite/issues
- npm.io page: https://npm.io/package/gulp-rev-rewrite

## Dependencies (1)

- [plugin-error](https://npm.io/package/plugin-error.md) ^2.0.1

## Recent versions

- 7.0.0 (latest) — 2026-07-16
- 6.0.0 — 2023-09-28
- 5.0.0 — 2021-07-31
- 4.0.0 — 2020-10-30
- 3.0.3 — 2020-04-03
- 3.0.2 — 2020-02-19
- 3.0.1 — 2020-01-30
- 3.0.0 — 2020-01-03
- 2.0.0 — 2019-07-02
- 1.1.4 — 2019-01-15
- 1.1.3 — 2018-11-27
- 1.1.2 — 2018-11-06
- 1.1.1 — 2018-05-24
- 1.1.0 — 2018-05-17
- 1.0.3 — 2018-05-14
- … 3 more at https://npm.io/package/gulp-rev-rewrite/versions

## README

# gulp-rev-rewrite 

[![Build Status](https://github.com/thomasvantuycom/gulp-rev-rewrite/actions/workflows/ci.yml/badge.svg)](https://github.com/thomasvantuycom/gulp-rev-rewrite/actions/workflows/ci.yml) [![npm](https://img.shields.io/npm/v/gulp-rev-rewrite.svg)](https://www.npmjs.com/package/gulp-rev-rewrite) [![semantic-release](https://img.shields.io/badge/%20%20%F0%9F%93%A6%F0%9F%9A%80-semantic--release-e10079.svg)](https://github.com/semantic-release/semantic-release)

Effortlessly rewrite references to revisioned assets by incorporating `gulp-rev-rewrite` into your revisioning workflow powered by [`gulp-rev`](https://github.com/sindresorhus/gulp-rev).

## Install

```sh
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.

```js
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.

```js
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](https://github.com/thomasvantuycom)

---
_Source: https://npm.io/package/gulp-rev-rewrite · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
