goodeggs-assets
v1.1.0
Published
Shared runtime code to manage assets
Downloads
2
Readme
goodeggs-assets
Shared runtime code to manage assets
Usage
npm install --save goodeggs-assets
var goodeggsAssets = require('goodeggs-assets');
var express = require('express');
var app = express();
app.use(goodeggsAssets.middleware());
When NODE_ENV
is production
:
- static assets will be served from
build/public
- assets will include far-future headers
goodeggsAssets.assetPath
will translate paths using the manifest atbuild/rev-manifest.json
For other values of NODE_ENV
:
- static assets will be served from
public
goodeggsAsets.assetPath
will simply echo back the requested path
The paths above are all configurable using your Assetfile
. See goodeggs-assets-cli for more information on the Assetfile
.
View Helper
res.locals.assetPath
will be set by the middleware, so if you're using an Express rendering engine, you can put calls like this.assetPath('/img/foo.jpg')
in your templates, and they'll be translated to versioned URLs in production.
Contributing
Please follow our Code of Conduct when contributing to this project.
$ git clone https://github.com/goodeggs/goodeggs-assets && cd goodeggs-assets
$ npm install
$ npm test
Module scaffold generated by generator-goodeggs-npm.