Socket
Socket
Sign inDemoInstall

express-asset-versions

Package Overview
Dependencies
3
Maintainers
2
Versions
3
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    express-asset-versions

Simple versioning for assets in express.js


Version published
Weekly downloads
64
decreased by-3.03%
Maintainers
2
Install size
98.2 kB
Created
Weekly downloads
 

Readme

Source

express-asset-versions NPM version

An express.js middleware and helper to prepend your static assets with a version string.

Usage

Setup

$ npm install express-asset-versions
var express = require('express')
  , assets = require('express-asset-versions')
  , app = express();

var assetPath = path.join(__dirname, 'public');
app.use('/public', express.static(assetPath));
app.use(assets('/public', assetPath));

app.listen(3000);

Templates

// EJS
<link rel="stylesheet" href="<%= asset('css/stylesheet.css') %>" />
// Jade
link(rel='stylesheet', href=asset('css/stylesheet.css'))
// Swig
<link rel="stylesheet" href="{{ asset('css/stylesheet.css') }}" />

// Result:
<link rel="stylesheet" href="/public/css/stylesheet.css?1f05a21474" />

The asset() helper takes an optional second parameter to define a file used in production (NODE_ENV=production):

<link rel="stylesheet" href="<%= asset('css/stylesheet.css', 'css/stylesheet.min.css') %>" />

// Result:
<link rel="stylesheet" href="/public/css/stylesheet.css?1f05a21474" />     // NODE_ENV=development
<link rel="stylesheet" href="/public/css/stylesheet.min.css?73d57ce89a" /> // NODE_ENV=production

Keywords

FAQs

Last updated on 03 Feb 2015

Did you know?

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

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc