# express-asset-versions

> Simple versioning for assets in express.js

Latest version **0.1.2** (published 2015-02-03) · MIT license · 0 weekly downloads

## Install

```sh
npm install express-asset-versions
pnpm add express-asset-versions
yarn add express-asset-versions
bun add express-asset-versions
```

## Health

**Score 15/100 (F)** — status: abandoned.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support; pre 1.0.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 0.1.2 |
| Published | 2015-02-03 |
| First published | 2014-03-17 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 1 |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 1 |
| Author | Patrick Stadler |
| Maintainers | pstadler, mweibel |
| Keywords | express, connect, assets, middleware, versions, cache-busting, development, production |

## Links

- npm: https://www.npmjs.com/package/express-asset-versions
- Repository: https://github.com/mila-labs/express-asset-versions
- Issues: https://github.com/mila-labs/express-asset-versions/issues
- npm.io page: https://npm.io/package/express-asset-versions

## Dependencies (1)

- [checksum](https://npm.io/package/checksum.md) ^0.1.1

## Alternatives

- [memory-cache](https://npm.io/package/memory-cache.md) — 795.0K weekly downloads
- [@httptoolkit/proxy-agent](https://npm.io/package/@httptoolkit/proxy-agent.md) — 11.2K weekly downloads
- [express-cache-controller](https://npm.io/package/express-cache-controller.md) — 5.3K weekly downloads
- [http-cache-middleware](https://npm.io/package/http-cache-middleware.md) — 4.5K weekly downloads
- [cache2](https://npm.io/package/cache2.md) — 1.5K weekly downloads

## Recent versions

- 0.1.2 (latest) — 2015-02-03
- 0.1.1 — 2014-03-17
- 0.1.0 — 2014-03-17

## README

# express-asset-versions [![NPM version][npm-image]][npm-url]

An [express.js](http://expressjs.com/) middleware and helper to
prepend your static assets with a version string.

## Usage

### Setup

```bash
$ npm install express-asset-versions
```

```javascript
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
```

[npm-url]: https://npmjs.org/package/express-asset-versions
[npm-image]: https://badge.fury.io/js/express-asset-versions.png

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