express-rev

0.1.2 • Public • Published

express-rev

Middleware which adds helper functions for dealing with manifest files and file fingerprints.

Setup

Configure your ExpressJS project based on the example below. Include this middleware before rendering a view.

// index.js (example ExpressJS application)
 
var express = require('express');
var manifest = require('express-rev');
var app = express();
 
app.set('views', './views');
app.set('view engine', 'jade');
 
app.use(rev({
  manifest: './public/assets/manifest.json',
  prepend: '/assets'
}));
app.use('/', express.static('./public'));
 
app.get('/', function (req, res) {
  res.render('index');
});
 
module.exports = app;

Now you can use rev function in your views to print file path.

// index.jade (example jade view)
 
doctype html
html(lang='en')
  head
    title Asset Fingerprint Example
    link(rel='stylesheet', type='text/css', href=assetPath('index.css'))
    script(type='text/javascript', src='assetPath(index.js'))
  body
    img(src=assetPath('logo.png'))

Now all you need is a good asset-pipeline module. Use gulp with gulp-devkit for that.

Config

Open defaults.json file to see the default configuration values.

manifest: String

Path to JSON manifest file (e.g this file will generate the gulp-rev-all plugin). Manifest replace-process is ignored if the file does not exist.

prepend: String

URL path where static route for assets should be mounted.

Package Sidebar

Install

npm i express-rev

Weekly Downloads

3

Version

0.1.2

License

MIT

Last publish

Collaborators

  • xpepermint