goodeggs-assets

1.1.0 • Public • Published

goodeggs-assets

Shared runtime code to manage assets

build status npm version MIT license we're hiring

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 at build/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.

Readme

Keywords

none

Package Sidebar

Install

npm i goodeggs-assets

Weekly Downloads

1

Version

1.1.0

License

MIT

Last publish

Collaborators

  • goodeggs-admin
  • bobzoller