Webpack loader to work in tandem with gulp-rev.
Switch branches/tags
Nothing to show
Clone or download


Gulp Rev Loader

This Webpack 2.x loader is designed to work in tandem with gulp-rev 👊.
For example, you might have a build process that uses gulp and gulp-rev to tag hashes on your rev'd images or files. Gulp-rev creates a manifest of the processed files. Using gulp-rev-loader checks your files against the rev-manifest and re-writes them to their rev'd paths at webpack compile time. You can also update path prefixes and hash out the file content based on file size.

Note: People using Webpack 1.x can still use the previous version of this loader.


npm install gulp-rev-loader

Configure a gulp-rev task

var gulp = require('gulp');
var rev = require('gulp-rev');

gulp.task('default', function() {
 return gulp.src('images/**/*.+(jpg|jpeg|ico|png|gif|svg)')

Configure the webpack loader

var webpack = require('webpack');
var path = require('path');

module.exports = {
    name: 'example',
    entry: {
        index: path.join(__dirname, 'app.js')
    output: {
        path: path.join(__dirname, 'dist'),
        publicPath: '/dist/',
        filename: '[name].bundle.[hash].js'
    resolve: {
        extensions: ['.json', '.js', '.jsx', '.scss', '.png', '.jpg', '.jpeg', '.gif']
    module: {
        loaders: [
                test: /\.json$/,
                loaders: ['json-loader']
                test: /\.(jpe?g|png|gif|svg)$/i,
                loader: 'gulp-rev-loader',
                query: {
                    debug: true,
                    limit: 5000,
                    hash: 'sha512',
                    digest: 'hex',
                    relativeSplit: 'images/',
                    prefix: 'images',
                    manifest: 'rev-manifest',
                    outputDir: path.join(__dirname, 'dist')

//optionally, use string of url params as options
//var manifestParams = '?debug=false&limit=5000&hash=sha512&digest=hex&relativeSplit=images/&prefix=images&manifest=rev-manifest&outputDir=' + path.join(__dirname, 'dist');


    debug: true, //bool to output logging info
    limit: 5000, //int to limit min k before hashing file src
    hash: 'sha512', //string hash type
    digest: 'hex', //string digest type
    relativeSplit: 'images/', //string to relative split point
    prefix: 'images', //string to prefix manifest replacements
    manifest: 'rev-manifest', //string path to manifest
    outputDir: path.join(__dirname, 'dist') //string path to output directory

Running the example

cd gulp-rev-loader/examples && gulp


npm install -g mocha && npm test