Asset manager easily allows you to switch between development and production css and js files in your templates by managing them in a single json file that's still compatible with grunt cssmin and uglify.

Asset manager easily allows you to switch between development and production css
and js files in your templates by managing them in a single json file that's
still compatible with grunt cssmin and uglify. A working demo/implimentation of
this can been seen in MEAN Stack.

##Usage
To use assetmanager, cd into your
project directory and install assetmanager with npm.

$ cd /to/project/directory

$ npm install assetmanager --save

Setup an external json asset configuration file that holds your development and
production css and js files. The format of this file can be in either
files object format,
or files array format.

You may also add external resources, however these entries should be 1-to-1 key value
pairs. External resources will not cause issues with grunt cssmin or uglify,
they will simply be treated as empty resources and thus ignored.

###Files Object Format
Files object format
consists of file groups (main, secondary, etc.) that contain file types (css,
js). Each file type has a destination file mapped to a list of files of which
the destination file is composed in production mode.

In the assets file below, the main js files might be passed
to grunt-contrib-uglify. The
output from that Grunt task would be in "public/build/js/main.min.js" - in
production mode, assetmanager will place that filename in the list of assets in
assets.main.js. In debug mode, assetmanager would flatten the lists of
js source files, placing the flattened list in assets.main.js. This makes
original, uncompressed js source files available in the browser during
debugging.

This format allows configuring a single Grunt target with multiple destinations.
For example, perhaps you'd like to concatenate vendor minified css and js files
in production. Both sets should have their own destination file as illustrated
in the assets configuration below with "vendorCss" and "vendorJs" file types.

In your node app require assetmanager, the example below is partial code
from an express setup. Call assetmanager.process with your files from your
assets.json config file. Set the debug value to toggle between your
compressed files and your development files. You can also set the webroot
value so that when assetmanager processes your files it will change
public/lib/angular/angular.js to /lib/angular/angular.js so that everything
is relative to your webroot.

For the sake of efficiency, assetmanager should be configured after your static
resources.