1.0.2 • Published 7 years ago

gulp-rev-update v1.0.2

Weekly downloads
13
License
MIT
Repository
github
Last release
7 years ago

gulp-rev-update Build Status

Update occurences of filenames which have been renamed by gulp-rev This plugin using rev-manifest.json file generated by gulp-rev

Install

$ npm install --save-dev gulp-rev-update

Usage

const rev = require('gulp-rev');
const revUpdate = require('gulp-rev-update');

gulp.task('rev', ['build:css', 'dist:js'], function(){
  return gulp.src(['build/**/*.css', 'build/**/*.js'])
    .pipe(rev())
    .pipe(gulp.dest(gulp.config.distFolder))
    .pipe(rev.manifest())
    .pipe(gulp.dest(gulp.config.distFolder))
})

gulp.task('rev-update', ['rev'], function(){
  const manifestFile = `./${gulp.config.distFolder}/rev-manifest.json`;

  return gulp.src(`${gulp.config.srcFolder}/index.html`)
    .pipe(revUpdate({ manifestFile }))
    .pipe(gulp.dest(gulp.config.distFolder));
});

API

revUpdate(options)

options.replaceInExtensions

Type: Array

Default: ['.css', '.html', '.hbs', '.php', '.twig', '.htm']

Only substitute in new filenames in files of these types.

You can modify it, for example if you want update xml files do like below:

const revUpdate = require('gulp-rev-update');

gulp.task('rev-update', ['rev'], function(){
  const manifestFile = `./${gulp.config.distFolder}/rev-manifest.json`;

  return gulp.src(`${gulp.config.srcFolder}/index.html`)
    .pipe(revUpdate({ manifestFile, replaceInExtensions: ['xml'] }))
    .pipe(gulp.dest(gulp.config.distFolder));
});

options.replaceReved

Type: boolean

Default: true

Use: replaceReved: false when you don't want to update reved filenames.

Streaming

This plugin does not support streaming. If you have files from a streaming source, such as Browserify, you should use gulp-buffer before gulp-rev-update in your pipeline:

const gulp = require('gulp');
const browserify = require('browserify');
const source = require('vinyl-source-stream');
const buff = require('gulp-buffer');
const revUpdate = require('gulp-rev-update');

gulp.task('rev-update', () =>
	browserify(`${gulp.config.srcFolder}/index.php`)
		.pipe(source('index.php'))
		.pipe(buff())
		.pipe(revUpdate())
		.pipe(gulp.dest(gulp.config.distFolder))
);

License

MIT © Jacek Świtoń