{"_id":"asset-smasher","_rev":"45-7ad23fe6957e8ae34450c613b3746459","name":"asset-smasher","description":"Asset pre-processor, merger, and compressor.","dist-tags":{"latest":"0.3.2"},"versions":{"0.1.0":{"name":"asset-smasher","description":"Asset pre-processor, merger, and compressor.","version":"0.1.0","author":{"name":"Jim Riecken","email":"jriecken@gmail.com"},"keywords":["asset","compress","merge","preprocess"],"license":{"type":"MIT","url":"http://github.com/jriecken/asset-smasher/raw/master/LICENSE"},"repository":{"type":"git","url":"git://github.com/jriecken/asset-smasher.git"},"bugs":{"url":"http://github.com/jriecken/asset-smasher/issues"},"main":"./lib/asset-smasher.js","bin":{"asset-smasher":"./bin/asset-smasher"},"dependencies":{"async":"0.1.18","commander":"0.6.0","glob":"3.1.9","mkdirp":"0.3.2","minimatch":"0.2.4","uglify-js":"1.3.0","underscore":"1.3.3"},"optionalDependencies":{},"devDependencies":{},"engines":{"node":">= 0.6.0"},"_npmUser":{"name":"jriecken","email":"jriecken@gmail.com"},"_id":"asset-smasher@0.1.0","_engineSupported":true,"_npmVersion":"1.1.19","_nodeVersion":"v0.6.16","_defaultsLoaded":true,"dist":{"shasum":"99e5e220e8c48bc01ed2e669d4b24cf3ad0df6d2","tarball":"https://registry.npmjs.org/asset-smasher/-/asset-smasher-0.1.0.tgz","integrity":"sha512-MVY8pay6RCGkacuhwj8IHdtawKoXTkOB6kt7r25wDHFjXxKkLslojVtT7XLjGstqj8ffE7dDsR99CKz+yWX6OA==","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEYCIQC3KP6v/FUbpFuFT3zFtDYwsJESroVlS3Be/rDJ45cNZQIhANswsclkyWlJTqp90a5vBfOzCbKV/h+SHJQUtdCP49lQ"}]},"maintainers":[{"name":"jriecken","email":"jriecken@gmail.com"}]},"0.1.1":{"name":"asset-smasher","description":"Asset pre-processor, merger, and compressor.","version":"0.1.1","author":{"name":"Jim Riecken","email":"jriecken@gmail.com"},"keywords":["asset","compress","merge","preprocess"],"license":{"type":"MIT","url":"http://github.com/jriecken/asset-smasher/raw/master/LICENSE"},"repository":{"type":"git","url":"git://github.com/jriecken/asset-smasher.git"},"bugs":{"url":"http://github.com/jriecken/asset-smasher/issues"},"main":"./lib/asset-smasher.js","bin":{"asset-smasher":"./bin/asset-smasher"},"dependencies":{"async":"0.1.18","commander":"0.6.0","glob":"3.1.9","mkdirp":"0.3.2","minimatch":"0.2.4","uglify-js":"1.3.0","underscore":"1.3.3"},"optionalDependencies":{},"devDependencies":{},"engines":{"node":">= 0.6.0"},"_npmUser":{"name":"jriecken","email":"jriecken@gmail.com"},"_id":"asset-smasher@0.1.1","_engineSupported":true,"_npmVersion":"1.1.19","_nodeVersion":"v0.6.16","_defaultsLoaded":true,"dist":{"shasum":"a3fa8e2f54ef4c581f1c717d55a4f1c26cb8e9ee","tarball":"https://registry.npmjs.org/asset-smasher/-/asset-smasher-0.1.1.tgz","integrity":"sha512-Mak7BD4xdDnEQui1gT1ALgKxGPWczcltPNih28AQR5baw5gSxIyaZcJK9Snqlz+Jup/eFgrIUGPbewzWU8OcTQ==","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEYCIQDkfsl4dl661lYTCuClbp8yRvMReemLjnXeopwqqRsG8gIhAMphjjjUzQXCsMceyy/CoaEHrzqqO/l+wHEx0GOxzUE4"}]},"maintainers":[{"name":"jriecken","email":"jriecken@gmail.com"}]},"0.1.2":{"name":"asset-smasher","description":"Asset pre-processor, merger, and compressor.","version":"0.1.2","author":{"name":"Jim Riecken","email":"jriecken@gmail.com"},"keywords":["asset","compress","merge","preprocess"],"license":{"type":"MIT","url":"http://github.com/jriecken/asset-smasher/raw/master/LICENSE"},"repository":{"type":"git","url":"git://github.com/jriecken/asset-smasher.git"},"bugs":{"url":"http://github.com/jriecken/asset-smasher/issues"},"main":"./lib/asset-smasher.js","bin":{"asset-smasher":"./bin/asset-smasher"},"dependencies":{"async":"0.1.22","commander":"0.6.1","glob":"3.1.10","mkdirp":"0.3.3","minimatch":"0.2.5","uglify-js":"1.3.2","underscore":"1.3.3"},"optionalDependencies":{},"devDependencies":{},"engines":{"node":">= 0.6.0"},"_npmUser":{"name":"jriecken","email":"jriecken@gmail.com"},"_id":"asset-smasher@0.1.2","_engineSupported":true,"_npmVersion":"1.1.19","_nodeVersion":"v0.6.16","_defaultsLoaded":true,"dist":{"shasum":"46805a147633524fb0249595f22f96268bd8fb92","tarball":"https://registry.npmjs.org/asset-smasher/-/asset-smasher-0.1.2.tgz","integrity":"sha512-iuPUdv1EKNWYauwRJPOLqtd0LM/lYdl+bYEl95is7Ft4RGYuu/8Uso+dUKRIgW+CgPc7noBypK5iEZ7vQRghSg==","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEYCIQCFFFc7+94TzVP4cXRVoHAIDStWZO6beYDmGIZKjAzVIwIhAIAySWeNO4DsbBPg1tGfx0vziXO2i0soOx2pC9ukxQPI"}]},"maintainers":[{"name":"jriecken","email":"jriecken@gmail.com"}]},"0.1.3":{"name":"asset-smasher","description":"Asset pre-processor, merger, and compressor.","version":"0.1.3","author":{"name":"Jim Riecken","email":"jriecken@gmail.com"},"keywords":["asset","compress","merge","preprocess"],"license":{"type":"MIT","url":"http://github.com/jriecken/asset-smasher/raw/master/LICENSE"},"repository":{"type":"git","url":"git://github.com/jriecken/asset-smasher.git"},"bugs":{"url":"http://github.com/jriecken/asset-smasher/issues"},"main":"./lib/asset-smasher.js","bin":{"asset-smasher":"./bin/asset-smasher"},"dependencies":{"async":"0.1.22","commander":"0.6.1","glob":"3.1.10","mkdirp":"0.3.3","minimatch":"0.2.5","uglify-js":"1.3.2","underscore":"1.3.3"},"optionalDependencies":{},"devDependencies":{},"engines":{"node":">= 0.6.0"},"readme":"# Asset Smasher\n\nAsset pre-processor, merger, and compressor for Node.js\n\n- [Structuring Your Assets](#structure-assets)\n    - [Manifest Files](#manifest-files)\n- [Using via Command Line](#command-line)\n    - [Helpers](#cli-helpers)\n    - [Plugins](#cli-plugins)\n- [Using via Express Middleware](#express-middleware)\n- [Using via Programmatic Interface](#programmatic-interface)\n- [Transformer Notes](#transformer-notes)\n    - [LESS](#tn-less)\n    - [ejs](#tn-ejs)\n    - [dust and Handlebars](#tn-dust-hbs)\n\n## Overview\n\nAsset Smasher is a command-line tool, express middleware, and programmatic interface for:\n\n- Pre-processing and transforming files down to plain JavaScript and CSS.\n    - `.coffee` - Compile CoffeeScript into JavaScript\n    - `.ejs` - Run a file through EJS (e.g. to populate configuration parameters into a JavaScript file)\n    - `.less` - Compile Less into CSS\n    - `.hbs` - Precompile Handlebars templates into JavaScript files that register them with `Handlebars.templates`.\n    - `.dust` - Precompile Dust templates into JavaScript files that register them for use with `dust.render`.\n    - Processors can be chained together.  E.g `test.js.hbs.ejs` (run Handlebars template through EJS, then compile it)\n    - Additional processors can be plugged in.\n- Merging files together using Manifest files (`.mf`) with dependency management directives similar to Sprockets.\n    - `require` - Require a single file\n    - `require_dir` - Require all the files in a specific directory\n    - `require_tree` - Require all the files in a specific directory (and subdirectories)\n- Compressing, gzipping, and generating hashed file names.\n    - Compress JavaScript files with `uglify-js`\n    - Compress LESS during LESS preprocessing\n    - Generate Gzipped versions of files\n    - Include a MD5 hash of the file's contents in the file name. `myAsset.js` -> `myAsset-c89cba7b7df028e65cb01d86f4d27077.js`\n        - `asset_path` helper that can be used to reference the hashed name.\n\nIt's released under the [MIT](http://en.wikipedia.org/wiki/MIT_License) license.\n\n## <a name=\"structure-assets\"></a> Structuring Your Assets\n\nAsset Smasher has the concept of \"asset paths\".  These are locations in which your asset files will be located, and from which any relative asset paths will be rooted to.\n\nThe simplest structure has one asset path.\n\nE.g.\n\n    Asset Paths\n    -----------\n     - app\n\n    File Structure\n    --------------\n    app/\n      js/\n      css/\n      images/\n\nA more complicated structure might be\n\n    Asset Paths\n    -----------\n     - app\n     - lib\n     - vendor\n\n    File Structure\n    --------------\n    app/\n      js/\n      css/\n      images/\n    lib/\n      js/\n      css/\n      images/\n    vendor/\n      js/\n      css/\n      images/\n\nBoth of these examples will result in a compiled structure of\n\n    js/\n    css/\n    images/\n\n### <a name=\"manifest-files\"></a> Manifest Files\n\nManifest (`.mf`) files are used to merge many assets into a single resulting file. The file should be named with the resulting file type before the `.mf` extension (e.g. `manifest.css.mf` or `manifest.js.mf`. *Manifest files can `require` other manifest files*\n\nA simple manifest file might look like\n\n    # A comment here\n    require \"./one.js\"\n    require_dir \"./subdir1\"\n    #\n    # Another comment\n    require_tree \"./subdir2\"\n\n**Directives:**\n\n<table border=\"1\" cellpadding=\"5\" cellspacing=\"0\" width=\"100%\">\n <thead>\n  <tr><th width=\"15%\">Directive</th><th width=\"85%\">Description</th></tr>\n </thead>\n <tbody>\n  <tr>\n    <td><code>require \"[path]\"</code></td>\n    <td>\n      <strong>Include a single file</strong>\n      <ul>\n       <li>\n         If the path starts with <code>\"/\"</code>, <code>\"../\"</code>, or <code>\"./\"</code>, process and include the specified file.  The file <em>must</em> be\n         inside one of the configured asset paths.\n       </li>\n       <li>\n         If the path does not start with <code>\"/\"</code>, <code>\"../\"</code>, or <code>\"./\"</code>, the file will be searched for in all of the configured\n         asset paths.  E.g. if there are asset paths <code>one</code> and <code>two</code> defined, <code>require \"js/test.js\"</code>\n         will look for <code>one/js/test.js</code> and then <code>two/js/test.js</code> stopping when it finds a matching file.\n       </li>\n       <li>\n         The filename part of the path does not have to include the whole extension.  E.g <code>require \"test\"</code>\n         finds the first file that matches the name in the asset paths (for example <code>test.js.ejs</code>)\n       </li>\n      </ul>\n    </td>\n  </tr>\n  <tr>\n    <td><code>require_dir \"[path]\"</code></td>\n    <td>\n      <strong>Include all the files in a directory</strong>\n      <ul>\n       <li>\n         The path must be absolute, or relative to the current directory.  E.g. you can do <code>require_dir \"../some/other/dir\"</code>\n         but not <code>require_dir \"somedir\"</code>\n       </li>\n       <li>\n         If using absolute paths, or <code>\"..\"</code> in your paths, the resulting directory needs to be inside one of the configured asset paths.\n       </li>\n       <li>\n         Make sure the directory only contains assets of the type you want.  E.g. for <code>myManifest.js.mf</code>, the dir required had better\n         only contain javascript files, or else bad things will happen.\n       </li>\n      </ul>\n    </td>\n  </tr>\n  <tr>\n    <td><code>require_tree \"[path]\"</code></td>\n    <td>\n      <strong>Include the files in a directory recursively</strong>\n      <ul>\n        <li>The rules for <code>require_tree</code> are the same as the rules for <code>require_dir</code></li>\n      </ul>\n    </td>\n  </tr>\n </tbody>\n</table>\n\n## <a name=\"command-line\"></a> Using via Command-Line\n\nUse `npm install -g asset-smasher` to install the `asset-smasher` command-line tool globally.\n\n      asset-smasher --help\n\n        Usage: asset-smasher [options] <output dir>\n\n        Options:\n\n          -h, --help               output usage information\n          -V, --version            output the version number\n          --compress               compress/minify the generated files\n          --hash                   generate versions of the files with md5 hashes in the name\n          --gzip                   generate gzipped versions of the compiled files\n          --hashVersion <version>  invalidate all assets without changing file contents [1.0]\n          --only <pattern,...>     only process the files matching these glob patterns (relative to any of the paths) [**/*]\n          --paths <path,...>       list of paths to look for assets [.]\n          --prefix <prefix>        prefix to append to logical paths when constructing urls. use if output dir is not served from the root of your web app []\n          --helpers <js_file>      a .js module of helper functions require()s to expose to transforms []\n          --plugins <js_file>      a .js plugin module []\n\n        If --only is not specified, *all* files in the --paths will be processed.\n\n        Examples:\n\n          Compile all assets in the current directory to /home/me/compiledAssets\n\n            $ asset-smasher /home/me/compiledAssets\n\n          Something similar to what the Rails asset pipeline does by default\n\n            $ asset-smasher --compress --hash --gzip --prefix=/assets \\\n                --paths=./js,./css,./images \\\n                --only **/*.{jpg,gif,png},application.js.mf,application.css.mf ./public/assets\n\n          Compile assets, providing some custom helpers to the transformation\n\n            $ asset-smasher --helpers helpers.js output\n\n### <a name=\"cli-helpers\"></a> Helpers\n\nThere is a built-in `asset_path` helper that can be used to get the \"real\" (i.e. with hashed file name) path of an asset.  E.g. `asset_path('css/myFile.css')` might return `'/assets/css/myFile-c89cba7b7df028e65cb01d86f4d27077.css`.\n\nSome transformers (e.g. the `.ejs` one) take in a set of local variables that they can use during transformation. You can pass in the path to a JavaScript module whose exports will be included in this set of variables.\n\nYou can use this, for example, to set configuration parameters in your JS files:\n\n**helper.js**\n\n    exports.serviceUrl = 'http://my.service/';\n\n**config.js.ejs**\n\n    //...\n    var serviceUrl = '<%= serviceUrl %>';\n    var cssLocation = '<%= asset_path('css/myFile.css') %>';\n    //...\n\n**Execution**\n\n    $ asset-smasher --helpers helper.js --only config.js.ejs,css/myFile.css .\n    $ cat config.js\n    var serviceUrl = 'http://my.service/';\n    var cssLocation = '/assets/css/myFile-c89cba7b7df028e65cb01d86f4d27077.css';\n\n\n### <a name=\"cli-plugins\"></a> Plugins\n\nIf there's a type of file you want to pre-process that is not natively supported by Asset Smasher, you can add it using a plugin file.\n\n*TODO: How to add additional transformers via a plugin file.*\n\n## <a name=\"express-middleware\"></a> Using via Express Middleware\n\nAsset smasher exposes an `express` middleware that can:\n\n- Serve your assets un-merged/mangled in development mode.\n- Serve precompiled assets (with hashed file names) in production mode.\n\nThe middleware takes in the same arguments as the `Smasher` constructor, with a few extras:\n\n- `serve` - boolean whether the middleware should serve the asset files.  Usualy set this to `true` in development, `false` in production\n- `assetMapLocation` - path to the `map.json` generated by the command-line `asset-smasher` util.  This allows the helper methods to determine what the hashed file names were\n\nThe middleware exposes two helpers to your views:\n\n- `js_asset(logicalPath)` - Render a `<script>` tag for the specified JS asset. When `serve` is true, this will \"explode\" manifests and write out a separate `<script>` for each required file.  This makes debugging much easier.\n- `css_asset(logicalPath)` - Render a `<link>` tag for the specified CSS asset.  Same thing happens when `serve` is true.\n\n### Example\n\n    var assetSmasher = require('asset-smasher');\n\n**Middleware config (Dev)**\n\n    app.use(assetSmasher.middleware({\n      serve: true,\n      paths: [path.join(__dirname, 'assetDir1'), path.join(__dirname, 'assetDir2')],\n      prefix: '/assets',\n      outputTo: path.join(__dirname, 'tmp')\n    }));\n\n**Middleware config (Prod)**\n\n    app.use(assetSmasher.middleware({\n      serve: false,\n      prefix: '/assets',\n      assetMapLocation: path.join(__dirname, 'public/assets/map.json')\n    }));\n\n**View (ejs here, but could be others)**\n\n    <!DOCTYPE html>\n    <html>\n    <head>\n      <title>Test</title>\n      <%- css_asset('application.css') %>\n      <%- js_asset('application.js') %>\n    </head>\n    <body>\n      This is a test\n    </body>\n    </html>\n\n## <a name=\"programmatic-interface\"></a> Using via Programmatic Interface\n\nYou can invoke Asset Smasher programmatically by `require`ing it.  You can also plug in additional transformers this way.\n\nThe `Smasher` object has the following methods:\n\n - `compileAssets(cb)` - Find and compile all the assets.\n - `compileSingleAsset(assetFilePath, cb)` - Compile a single asset (assetFilePath is the actual path to the file, not a logical path)\n - `findAssets(cb)` - Find, but don't compile the assets.  Good for determining dependency graph without compiling.\n - `getAssetByLogicalPath(logicalPath)` - Get information about an asset by its logical path.  Only call this after finding/compiling assets.\n - `getHashedFileMapping()` - When `hash` is true, this returns a mapping of logical path to \"hashed\" logical path.  This object is what the command-line tool outputs to `map.json`. Only call this after finding/compiling assets.\n - `getRequiredLogicalPathsFor(asset)` - Get the logical paths of the assets that should be merged into the specified asset (populated for `.mf` files). Only call this after finding/compiling assets.\n - `getProcessingOrderLogicalPaths()` - Get a list of the order in which assets should be processed in order to satisfy all dependencies. Only call this after finding/compiling assets.\n - `reset()` - Reset the asset metadata.\n\nThe `Asset` object returned by `getAssetByLogicalPath` has the following properties (and one method):\n\n - `logicalPath` - The logical path\n - `hashedPath` - If `hash` is true, the hashed filename path, otherwise the same as `logicalPath`\n - `assetFilePath` - The full path to the actual source asset\n - `compiled` - Whether the asset has been compiled\n - `compiledAssetFilePath` - The full path to the compiled asset file\n - `reset()` - Set the asset back to its before-compile state (clear out contents, set name back to pre-transform name)\n\n**Example**\n\n    var assetSmasher = require('asset-smasher');\n    var Smasher = assetSmasher.Smasher;\n\n    // Plug in a custom transformer\n    assetSmasher.transforms['MyAwesomeFormat'] = require('myAwesomeFormatTransformer');\n\n    var sm = new Smasher({\n      paths:['/path/one', '/path/two'],\n      only:['**/*.{jpg,gif,png}', 'application.js.mf', 'application.css.mf'],\n      prefix:'/assets',\n      compress:true,\n      hash:true,\n      hashVersion:'1.0',\n      gzip:true,\n      outputTo:__dirname + '/public/assets',\n      helpers:{\n       my: 'helper',\n       another: 'helper'\n      }\n    });\n    sm.compileAssets(function(err) {\n      if(err) {\n        console.log('An error occurred', err);\n      } else {\n        console.log('Compilation done!');\n      }\n    });\n\n## <a name=\"transformer-notes\"></a> Transformer Notes\n\n### <a name=\"tn-less\"></a> LESS\n\n- When the `compress` option is true, the compression is done directly via the `less` compiler\n- Any `@include` paths are *relative to the path that the file is in*.\n- Any `@include`d files will *not* be processed individually by Asset Smasher (i.e. you can't `@include` a LESS file that is preprocessed by ejs)\n\n### <a name=\"tn-ejs\"></a> ejs\n\n- Any registered helpers will be exposed as global variables to the `ejs` transform.\n- The built-in `asset_paths` helper can be used here.\n\n### <a name=\"tn-dust-hbs\"></a> dust and Handlebars\n\n- The name of the template will be the template's \"logical path\" (minus the asset path it is in), minus the `.js.dust` or `.js.hbs` file extension.\n    - E.g. `/my/templates/test.js.dust`'s template name will be `test` (assuming `/my/templates` is the asset path)\n","_id":"asset-smasher@0.1.3","dist":{"shasum":"89d44abe8b05f5c7a4b56cd170915ad82185f697","tarball":"https://registry.npmjs.org/asset-smasher/-/asset-smasher-0.1.3.tgz","integrity":"sha512-9AR6PwezC11F3Y0apR7a/wYUBR63bVX3YBGz8TdLiEJBZkZ1rb+EuzZZcUkCaekXsXmEhUWePqXKO6T+YtTY0A==","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIH0Giix3W74RZOblJMfLWqdAA9fmsXmS+khIhMiqy5WpAiEA3yMUFUIeY2Z6OI73xW8TAVrM0aoRuL45RBnZrB2vQDg="}]},"maintainers":[{"name":"jriecken","email":"jriecken@gmail.com"}]},"0.1.4":{"name":"asset-smasher","description":"Asset pre-processor, merger, and compressor.","version":"0.1.4","author":{"name":"Jim Riecken","email":"jriecken@gmail.com"},"keywords":["asset","compress","merge","preprocess"],"license":{"type":"MIT","url":"http://github.com/jriecken/asset-smasher/raw/master/LICENSE"},"repository":{"type":"git","url":"git://github.com/jriecken/asset-smasher.git"},"bugs":{"url":"http://github.com/jriecken/asset-smasher/issues"},"main":"./lib/asset-smasher.js","bin":{"asset-smasher":"./bin/asset-smasher"},"dependencies":{"async":"0.1.22","commander":"0.6.1","glob":"3.1.10","mkdirp":"0.3.3","minimatch":"0.2.5","uglify-js":"1.3.2","underscore":"1.3.3"},"optionalDependencies":{},"devDependencies":{},"engines":{"node":">= 0.6.0"},"readme":"# Asset Smasher\n\nAsset pre-processor, merger, and compressor for Node.js\n\n- [Structuring Your Assets](#structure-assets)\n    - [Manifest Files](#manifest-files)\n- [Using via Command Line](#command-line)\n    - [Helpers](#cli-helpers)\n    - [Plugins](#cli-plugins)\n- [Using via Express Middleware](#express-middleware)\n- [Using via Programmatic Interface](#programmatic-interface)\n- [Transformer Notes](#transformer-notes)\n    - [LESS](#tn-less)\n    - [ejs](#tn-ejs)\n    - [dust and Handlebars](#tn-dust-hbs)\n\n## Overview\n\nAsset Smasher is a command-line tool, express middleware, and programmatic interface for:\n\n- Pre-processing and transforming files down to plain JavaScript and CSS.\n    - `.coffee` - Compile CoffeeScript into JavaScript\n    - `.ejs` - Run a file through EJS (e.g. to populate configuration parameters into a JavaScript file)\n    - `.less` - Compile Less into CSS\n    - `.hbs` - Precompile Handlebars templates into JavaScript files that register them with `Handlebars.templates`.\n    - `.dust` - Precompile Dust templates into JavaScript files that register them for use with `dust.render`.\n    - Processors can be chained together.  E.g `test.js.hbs.ejs` (run Handlebars template through EJS, then compile it)\n    - Additional processors can be plugged in.\n- Merging files together using Manifest files (`.mf`) with dependency management directives similar to Sprockets.\n    - `require` - Require a single file\n    - `require_dir` - Require all the files in a specific directory\n    - `require_tree` - Require all the files in a specific directory (and subdirectories)\n- Compressing, gzipping, and generating hashed file names.\n    - Compress JavaScript files with `uglify-js`\n    - Compress LESS during LESS preprocessing\n    - Generate Gzipped versions of files\n    - Include a MD5 hash of the file's contents in the file name. `myAsset.js` -> `myAsset-c89cba7b7df028e65cb01d86f4d27077.js`\n        - `asset_path` helper that can be used to reference the hashed name.\n\nIt's released under the [MIT](http://en.wikipedia.org/wiki/MIT_License) license.\n\n## <a name=\"structure-assets\"></a> Structuring Your Assets\n\nAsset Smasher has the concept of \"asset paths\".  These are locations in which your asset files will be located, and from which any relative asset paths will be rooted to.\n\nThe simplest structure has one asset path.\n\nE.g.\n\n    Asset Paths\n    -----------\n     - app\n\n    File Structure\n    --------------\n    app/\n      js/\n      css/\n      images/\n\nA more complicated structure might be\n\n    Asset Paths\n    -----------\n     - app\n     - lib\n     - vendor\n\n    File Structure\n    --------------\n    app/\n      js/\n      css/\n      images/\n    lib/\n      js/\n      css/\n      images/\n    vendor/\n      js/\n      css/\n      images/\n\nBoth of these examples will result in a compiled structure of\n\n    js/\n    css/\n    images/\n\n### <a name=\"manifest-files\"></a> Manifest Files\n\nManifest (`.mf`) files are used to merge many assets into a single resulting file. The file should be named with the resulting file type before the `.mf` extension (e.g. `manifest.css.mf` or `manifest.js.mf`. *Manifest files can `require` other manifest files*\n\nA simple manifest file might look like\n\n    # A comment here\n    require \"./one.js\"\n    require_dir \"./subdir1\"\n    #\n    # Another comment\n    require_tree \"./subdir2\"\n\n**Directives:**\n\n<table border=\"1\" cellpadding=\"5\" cellspacing=\"0\" width=\"100%\">\n <thead>\n  <tr><th width=\"15%\">Directive</th><th width=\"85%\">Description</th></tr>\n </thead>\n <tbody>\n  <tr>\n    <td><code>require \"[path]\"</code></td>\n    <td>\n      <strong>Include a single file</strong>\n      <ul>\n       <li>\n         If the path starts with <code>\"/\"</code>, <code>\"../\"</code>, or <code>\"./\"</code>, process and include the specified file.  The file <em>must</em> be\n         inside one of the configured asset paths.\n       </li>\n       <li>\n         If the path does not start with <code>\"/\"</code>, <code>\"../\"</code>, or <code>\"./\"</code>, the file will be searched for in all of the configured\n         asset paths.  E.g. if there are asset paths <code>one</code> and <code>two</code> defined, <code>require \"js/test.js\"</code>\n         will look for <code>one/js/test.js</code> and then <code>two/js/test.js</code> stopping when it finds a matching file.\n       </li>\n       <li>\n         The filename part of the path does not have to include the whole extension.  E.g <code>require \"test\"</code>\n         finds the first file that matches the name in the asset paths (for example <code>test.js.ejs</code>)\n       </li>\n      </ul>\n    </td>\n  </tr>\n  <tr>\n    <td><code>require_dir \"[path]\"</code></td>\n    <td>\n      <strong>Include all the files in a directory</strong>\n      <ul>\n       <li>\n         The path must be absolute, or relative to the current directory.  E.g. you can do <code>require_dir \"../some/other/dir\"</code>\n         but not <code>require_dir \"somedir\"</code>\n       </li>\n       <li>\n         If using absolute paths, or <code>\"..\"</code> in your paths, the resulting directory needs to be inside one of the configured asset paths.\n       </li>\n       <li>\n         Make sure the directory only contains assets of the type you want.  E.g. for <code>myManifest.js.mf</code>, the dir required had better\n         only contain javascript files, or else bad things will happen.\n       </li>\n      </ul>\n    </td>\n  </tr>\n  <tr>\n    <td><code>require_tree \"[path]\"</code></td>\n    <td>\n      <strong>Include the files in a directory recursively</strong>\n      <ul>\n        <li>The rules for <code>require_tree</code> are the same as the rules for <code>require_dir</code></li>\n      </ul>\n    </td>\n  </tr>\n </tbody>\n</table>\n\n## <a name=\"command-line\"></a> Using via Command-Line\n\nUse `npm install -g asset-smasher` to install the `asset-smasher` command-line tool globally.\n\n      asset-smasher --help\n\n        Usage: asset-smasher [options] <output dir>\n\n        Options:\n\n          -h, --help               output usage information\n          -V, --version            output the version number\n          --compress               compress/minify the generated files\n          --hash                   generate versions of the files with md5 hashes in the name\n          --gzip                   generate gzipped versions of the compiled files\n          --hashVersion <version>  invalidate all assets without changing file contents [1.0]\n          --only <pattern,...>     only process the files matching these glob patterns (relative to any of the paths) [**/*]\n          --paths <path,...>       list of paths to look for assets [.]\n          --prefix <prefix>        prefix to append to logical paths when constructing urls. use if output dir is not served from the root of your web app []\n          --helpers <js_file>      a .js module of helper functions require()s to expose to transforms []\n          --plugins <js_file>      a .js plugin module []\n\n        If --only is not specified, *all* files in the --paths will be processed.\n\n        Examples:\n\n          Compile all assets in the current directory to /home/me/compiledAssets\n\n            $ asset-smasher /home/me/compiledAssets\n\n          Something similar to what the Rails asset pipeline does by default\n\n            $ asset-smasher --compress --hash --gzip --prefix=/assets \\\n                --paths=./js,./css,./images \\\n                --only **/*.{jpg,gif,png},application.js.mf,application.css.mf ./public/assets\n\n          Compile assets, providing some custom helpers to the transformation\n\n            $ asset-smasher --helpers helpers.js output\n\n### <a name=\"cli-helpers\"></a> Helpers\n\nThere is a built-in `asset_path` helper that can be used to get the \"real\" (i.e. with hashed file name) path of an asset.  E.g. `asset_path('css/myFile.css')` might return `'/assets/css/myFile-c89cba7b7df028e65cb01d86f4d27077.css`.\n\nSome transformers (e.g. the `.ejs` one) take in a set of local variables that they can use during transformation. You can pass in the path to a JavaScript module whose exports will be included in this set of variables.\n\nYou can use this, for example, to set configuration parameters in your JS files:\n\n**helper.js**\n\n    exports.serviceUrl = 'http://my.service/';\n\n**config.js.ejs**\n\n    //...\n    var serviceUrl = '<%= serviceUrl %>';\n    var cssLocation = '<%= asset_path('css/myFile.css') %>';\n    //...\n\n**Execution**\n\n    $ asset-smasher --helpers helper.js --only config.js.ejs,css/myFile.css .\n    $ cat config.js\n    var serviceUrl = 'http://my.service/';\n    var cssLocation = '/assets/css/myFile-c89cba7b7df028e65cb01d86f4d27077.css';\n\n\n### <a name=\"cli-plugins\"></a> Plugins\n\nIf there's a type of file you want to pre-process that is not natively supported by Asset Smasher, you can add it using a plugin file.\n\n*TODO: How to add additional transformers via a plugin file.*\n\n## <a name=\"express-middleware\"></a> Using via Express Middleware\n\nAsset smasher exposes an `express` middleware that can:\n\n- Serve your assets un-merged/mangled in development mode.\n- Serve precompiled assets (with hashed file names) in production mode.\n\nThe middleware takes in the same arguments as the `Smasher` constructor, with a few extras:\n\n- `serve` - boolean whether the middleware should serve the asset files.  Usualy set this to `true` in development, `false` in production\n- `assetMapLocation` - path to the `map.json` generated by the command-line `asset-smasher` util.  This allows the helper methods to determine what the hashed file names were\n\nThe middleware exposes two helpers to your views:\n\n- `js_asset(logicalPath)` - Render a `<script>` tag for the specified JS asset. When `serve` is true, this will \"explode\" manifests and write out a separate `<script>` for each required file.  This makes debugging much easier.\n- `css_asset(logicalPath)` - Render a `<link>` tag for the specified CSS asset.  Same thing happens when `serve` is true as with `js_asset`.\n- `raw_asset(logicalPath)` - Return the path to the asset.\n\n### Example\n\n    var assetSmasher = require('asset-smasher');\n\n**Middleware config (Dev)**\n\n    app.use(assetSmasher.middleware({\n      serve: true,\n      paths: [path.join(__dirname, 'assetDir1'), path.join(__dirname, 'assetDir2')],\n      prefix: '/assets',\n      outputTo: path.join(__dirname, 'tmp')\n    }));\n\n**Middleware config (Prod)**\n\n    app.use(assetSmasher.middleware({\n      serve: false,\n      prefix: '/assets',\n      assetMapLocation: path.join(__dirname, 'public/assets/map.json')\n    }));\n\n**View (ejs here, but could be others)**\n\n    <!DOCTYPE html>\n    <html>\n    <head>\n      <title>Test</title>\n      <%- css_asset('application.css') %>\n      <%- js_asset('application.js') %>\n    </head>\n    <body>\n      This is a test\n    </body>\n    </html>\n\n## <a name=\"programmatic-interface\"></a> Using via Programmatic Interface\n\nYou can invoke Asset Smasher programmatically by `require`ing it.  You can also plug in additional transformers this way.\n\nThe `Smasher` object has the following methods:\n\n - `compileAssets(cb)` - Find and compile all the assets.\n - `compileSingleAsset(assetFilePath, cb)` - Compile a single asset (assetFilePath is the actual path to the file, not a logical path)\n - `findAssets(cb)` - Find, but don't compile the assets.  Good for determining dependency graph without compiling.\n - `getAssetByLogicalPath(logicalPath)` - Get information about an asset by its logical path.  Only call this after finding/compiling assets.\n - `getHashedFileMapping()` - When `hash` is true, this returns a mapping of logical path to \"hashed\" logical path.  This object is what the command-line tool outputs to `map.json`. Only call this after finding/compiling assets.\n - `getRequiredLogicalPathsFor(asset)` - Get the logical paths of the assets that should be merged into the specified asset (populated for `.mf` files). Only call this after finding/compiling assets.\n - `getProcessingOrderLogicalPaths()` - Get a list of the order in which assets should be processed in order to satisfy all dependencies. Only call this after finding/compiling assets.\n - `reset()` - Reset the asset metadata.\n\nThe `Asset` object returned by `getAssetByLogicalPath` has the following properties (and one method):\n\n - `logicalPath` - The logical path\n - `hashedPath` - If `hash` is true, the hashed filename path, otherwise the same as `logicalPath`\n - `assetFilePath` - The full path to the actual source asset\n - `compiled` - Whether the asset has been compiled\n - `compiledAssetFilePath` - The full path to the compiled asset file\n - `reset()` - Set the asset back to its before-compile state (clear out contents, set name back to pre-transform name)\n\n**Example**\n\n    var assetSmasher = require('asset-smasher');\n    var Smasher = assetSmasher.Smasher;\n\n    // Plug in a custom transformer\n    assetSmasher.transforms['MyAwesomeFormat'] = require('myAwesomeFormatTransformer');\n\n    var sm = new Smasher({\n      paths:['/path/one', '/path/two'],\n      only:['**/*.{jpg,gif,png}', 'application.js.mf', 'application.css.mf'],\n      prefix:'/assets',\n      compress:true,\n      hash:true,\n      hashVersion:'1.0',\n      gzip:true,\n      outputTo:__dirname + '/public/assets',\n      helpers:{\n       my: 'helper',\n       another: 'helper'\n      }\n    });\n    sm.compileAssets(function(err) {\n      if(err) {\n        console.log('An error occurred', err);\n      } else {\n        console.log('Compilation done!');\n      }\n    });\n\n## <a name=\"transformer-notes\"></a> Transformer Notes\n\n### <a name=\"tn-less\"></a> LESS\n\n- When the `compress` option is true, the compression is done directly via the `less` compiler\n- Any `@include` paths are *relative to the path that the file is in*.\n- Any `@include`d files will *not* be processed individually by Asset Smasher (i.e. you can't `@include` a LESS file that is preprocessed by ejs)\n\n### <a name=\"tn-ejs\"></a> ejs\n\n- Any registered helpers will be exposed as global variables to the `ejs` transform.\n- The built-in `asset_paths` helper can be used here.\n\n### <a name=\"tn-dust-hbs\"></a> dust and Handlebars\n\n- The name of the template will be the template's \"logical path\" (minus the asset path it is in), minus the `.js.dust` or `.js.hbs` file extension.\n    - E.g. `/my/templates/test.js.dust`'s template name will be `test` (assuming `/my/templates` is the asset path)\n","_id":"asset-smasher@0.1.4","dist":{"shasum":"c1d0364be7d903ff0e5d614fe2896ca24f7c00bb","tarball":"https://registry.npmjs.org/asset-smasher/-/asset-smasher-0.1.4.tgz","integrity":"sha512-tnjNdPxyGT1t8yyod40mFxzN+Te8UEwXVXCA6oHAXV7fwaDB97ezuJqscwP6ht40tG7YSU4sXGEKeMB4lZ/9rQ==","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIQCuq1QLglWM3CRv1d7KUW3x9d+dPAYUpgr+oLboljFWogIgIIb/+N5X5rXgmLOqlLXjtab4DnRSNwAL9HEqMmd1eK0="}]},"maintainers":[{"name":"jriecken","email":"jriecken@gmail.com"}]},"0.2.0":{"name":"asset-smasher","description":"Asset pre-processor, merger, and compressor.","version":"0.2.0","author":{"name":"Jim Riecken","email":"jriecken@gmail.com"},"keywords":["asset","compress","merge","preprocess"],"license":{"type":"MIT","url":"http://github.com/jriecken/asset-smasher/raw/master/LICENSE"},"repository":{"type":"git","url":"git://github.com/jriecken/asset-smasher.git"},"bugs":{"url":"http://github.com/jriecken/asset-smasher/issues"},"main":"./lib/asset-smasher.js","bin":{"asset-smasher":"./bin/asset-smasher"},"dependencies":{"async":"0.1.22","commander":"0.6.1","glob":"3.1.10","mkdirp":"0.3.3","minimatch":"0.2.5","uglify-js":"1.3.2","underscore":"1.3.3"},"optionalDependencies":{},"devDependencies":{},"engines":{"node":">= 0.6.0"},"_npmUser":{"name":"jriecken","email":"jriecken@gmail.com"},"_id":"asset-smasher@0.2.0","_engineSupported":true,"_npmVersion":"1.1.21","_nodeVersion":"v0.6.17","_defaultsLoaded":true,"dist":{"shasum":"6fac44186b58ac3f35b2efbaf66a018c471814ab","tarball":"https://registry.npmjs.org/asset-smasher/-/asset-smasher-0.2.0.tgz","integrity":"sha512-FLFDTqBzT7vmDvrphMF2ZS8LIwa+2ac8q92m+isIa/dkQxU5kYKiM2zcTxOF+vPNpcVPHAPFKfKV9uTD+1CGpg==","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEYCIQDn+EsVW1zSfhSenLgZfp1XqbVDkWm1w2ciJFXeYMcSXAIhAKfSxRsQbY9wdszRjHn6YOCl9DGbhpVMwu7kXLT1dSWF"}]},"maintainers":[{"name":"jriecken","email":"jriecken@gmail.com"}]},"0.2.1":{"name":"asset-smasher","description":"Asset pre-processor, merger, and compressor.","version":"0.2.1","author":{"name":"Jim Riecken","email":"jriecken@gmail.com"},"keywords":["asset","compress","merge","preprocess"],"license":{"type":"MIT","url":"http://github.com/jriecken/asset-smasher/raw/master/LICENSE"},"repository":{"type":"git","url":"git://github.com/jriecken/asset-smasher.git"},"bugs":{"url":"http://github.com/jriecken/asset-smasher/issues"},"main":"./lib/asset-smasher.js","bin":{"asset-smasher":"./bin/asset-smasher"},"dependencies":{"async":"0.1.22","commander":"0.6.1","glob":"3.1.10","mkdirp":"0.3.3","minimatch":"0.2.5","uglify-js":"1.3.2","underscore":"1.3.3"},"optionalDependencies":{},"devDependencies":{},"engines":{"node":">= 0.6.0"},"readme":"# Asset Smasher\n\nAsset pre-processor, merger, and compressor for Node.js\n\n- [Structuring Your Assets](#structure-assets)\n    - [Manifest Files](#manifest-files)\n- [Using via Command Line](#command-line)\n    - [Helpers](#cli-helpers)\n    - [Plugins](#cli-plugins)\n- [Using via Express Middleware](#express-middleware)\n- [Using via Programmatic Interface](#programmatic-interface)\n- [Transformer Notes](#transformer-notes)\n    - [LESS/Stylus](#tn-less-styl)\n    - [ejs](#tn-ejs)\n    - [dust and Handlebars](#tn-dust-hbs)\n\n## Overview\n\nAsset Smasher is a command-line tool, express middleware, and programmatic interface for:\n\n- Pre-processing and transforming files down to plain JavaScript and CSS.\n    - `.coffee` - Compile CoffeeScript into JavaScript\n    - `.ejs` - Run a file through EJS (e.g. to populate configuration parameters into a JavaScript file)\n    - `.less` - Compile Less into CSS\n    - `.styl` - Compile Stylus into CSS\n    - `.hbs` - Precompile Handlebars templates into JavaScript files that register them with `Handlebars.templates`.\n    - `.dust` - Precompile Dust templates into JavaScript files that register them for use with `dust.render`.\n    - Processors can be chained together.  E.g `test.js.hbs.ejs` (run Handlebars template through EJS, then compile it)\n    - Additional processors can be plugged in.\n- Merging files together using Manifest files (`.mf`) with dependency management directives similar to Sprockets.\n    - `require` - Require a single file\n    - `require_dir` - Require all the files in a specific directory\n    - `require_tree` - Require all the files in a specific directory (and subdirectories)\n- Compressing, gzipping, and generating hashed file names.\n    - Compress JavaScript files with `uglify-js`\n    - Compress LESS during LESS preprocessing\n    - Generate Gzipped versions of files\n    - Include a MD5 hash of the file's contents in the file name. `myAsset.js` -> `myAsset-c89cba7b7df028e65cb01d86f4d27077.js`\n        - `asset_path` helper that can be used to reference the hashed name.\n\nIt's released under the [MIT](http://en.wikipedia.org/wiki/MIT_License) license.\n\n## <a name=\"structure-assets\"></a> Structuring Your Assets\n\nAsset Smasher has the concept of \"asset paths\".  These are locations in which your asset files will be located, and from which any relative asset paths will be rooted to.\n\nThe simplest structure has one asset path.\n\nE.g.\n\n    Asset Paths\n    -----------\n     - app\n\n    File Structure\n    --------------\n    app/\n      js/\n      css/\n      images/\n\nA more complicated structure might be\n\n    Asset Paths\n    -----------\n     - app\n     - lib\n     - vendor\n\n    File Structure\n    --------------\n    app/\n      js/\n      css/\n      images/\n    lib/\n      js/\n      css/\n      images/\n    vendor/\n      js/\n      css/\n      images/\n\nBoth of these examples will result in a compiled structure of\n\n    js/\n    css/\n    images/\n\n### <a name=\"manifest-files\"></a> Manifest Files\n\nManifest (`.mf`) files are used to merge many assets into a single resulting file. The file should be named with the resulting file type before the `.mf` extension (e.g. `manifest.css.mf` or `manifest.js.mf`. *Manifest files can `require` other manifest files*\n\nA simple manifest file might look like\n\n    # A comment here\n    require \"./one.js\"\n    require_dir \"./subdir1\"\n    #\n    # Another comment\n    require_tree \"./subdir2\"\n\n**Directives:**\n\n<table border=\"1\" cellpadding=\"5\" cellspacing=\"0\" width=\"100%\">\n <thead>\n  <tr><th width=\"15%\">Directive</th><th width=\"85%\">Description</th></tr>\n </thead>\n <tbody>\n  <tr>\n    <td><code>require \"[path]\"</code></td>\n    <td>\n      <strong>Include a single file</strong>\n      <ul>\n       <li>\n         If the path starts with <code>\"/\"</code>, <code>\"../\"</code>, or <code>\"./\"</code>, process and include the specified file.  The file <em>must</em> be\n         inside one of the configured asset paths.\n       </li>\n       <li>\n         If the path does not start with <code>\"/\"</code>, <code>\"../\"</code>, or <code>\"./\"</code>, the file will be searched for in all of the configured\n         asset paths.  E.g. if there are asset paths <code>one</code> and <code>two</code> defined, <code>require \"js/test.js\"</code>\n         will look for <code>one/js/test.js</code> and then <code>two/js/test.js</code> stopping when it finds a matching file.\n       </li>\n       <li>\n         The filename part of the path does not have to include the whole extension.  E.g <code>require \"test\"</code>\n         finds the first file that matches the name in the asset paths (for example <code>test.js.ejs</code>)\n       </li>\n      </ul>\n    </td>\n  </tr>\n  <tr>\n    <td><code>require_dir \"[path]\"</code></td>\n    <td>\n      <strong>Include all the files in a directory</strong>\n      <ul>\n       <li>\n         The path must be absolute, or relative to the current directory.  E.g. you can do <code>require_dir \"../some/other/dir\"</code>\n         but not <code>require_dir \"somedir\"</code>\n       </li>\n       <li>\n         If using absolute paths, or <code>\"..\"</code> in your paths, the resulting directory needs to be inside one of the configured asset paths.\n       </li>\n       <li>\n         Make sure the directory only contains assets of the type you want.  E.g. for <code>myManifest.js.mf</code>, the dir required had better\n         only contain javascript files, or else bad things will happen.\n       </li>\n      </ul>\n    </td>\n  </tr>\n  <tr>\n    <td><code>require_tree \"[path]\"</code></td>\n    <td>\n      <strong>Include the files in a directory recursively</strong>\n      <ul>\n        <li>The rules for <code>require_tree</code> are the same as the rules for <code>require_dir</code></li>\n      </ul>\n    </td>\n  </tr>\n </tbody>\n</table>\n\n## <a name=\"command-line\"></a> Using via Command-Line\n\nUse `npm install -g asset-smasher` to install the `asset-smasher` command-line tool globally.\n\n      asset-smasher --help\n\n        Usage: asset-smasher [options] <output dir>\n\n        Options:\n\n          -h, --help               output usage information\n          -V, --version            output the version number\n          --compress               compress/minify the generated files\n          --hash                   generate versions of the files with md5 hashes in the name\n          --gzip                   generate gzipped versions of the compiled files\n          --hashVersion <version>  invalidate all assets without changing file contents [1.0]\n          --only <pattern,...>     only process the files matching these glob patterns (relative to any of the paths) [**/*]\n          --paths <path,...>       list of paths to look for assets [.]\n          --prefix <prefix>        prefix to append to logical paths when constructing urls. use if output dir is not served from the root of your web app []\n          --helpers <js_file>      a .js module of helper functions require()s to expose to transforms []\n          --plugins <js_file>      a .js plugin module []\n\n        If --only is not specified, *all* files in the --paths will be processed.\n\n        Examples:\n\n          Compile all assets in the current directory to /home/me/compiledAssets\n\n            $ asset-smasher /home/me/compiledAssets\n\n          Something similar to what the Rails asset pipeline does by default\n\n            $ asset-smasher --compress --hash --gzip --prefix /assets \\\n                --paths ./js,./css,./images \\\n                --only **/*.{jpg,gif,png},application.js.mf,application.css.mf ./public/assets\n\n          Compile assets, providing some custom helpers to the transformation\n\n            $ asset-smasher --helpers helpers.js output\n\n### <a name=\"cli-helpers\"></a> Helpers\n\nThere is a built-in `asset_path` helper that can be used to get the \"real\" (i.e. with hashed file name) path of an asset.  E.g. `asset_path('css/myFile.css')` might return `'/assets/css/myFile-c89cba7b7df028e65cb01d86f4d27077.css`.\n\nSome transformers (e.g. the `.ejs` one) take in a set of local variables that they can use during transformation. You can pass in the path to a JavaScript module whose exports will be included in this set of variables.\n\nYou can use this, for example, to set configuration parameters in your JS files:\n\n**helper.js**\n\n    exports.serviceUrl = 'http://my.service/';\n\n**config.js.ejs**\n\n    //...\n    var serviceUrl = '<%= serviceUrl %>';\n    var cssLocation = '<%= asset_path('css/myFile.css') %>';\n    //...\n\n**Execution**\n\n    $ asset-smasher --helpers helper.js --only config.js.ejs,css/myFile.css .\n    $ cat config.js\n    var serviceUrl = 'http://my.service/';\n    var cssLocation = '/assets/css/myFile-c89cba7b7df028e65cb01d86f4d27077.css';\n\n\n### <a name=\"cli-plugins\"></a> Plugins\n\nIf there's a type of file you want to pre-process that is not natively supported by Asset Smasher, you can add it using a plugin file.\n\nFor an example of what the transformer classes look like, look in the `lib/compilation/transforms` directory\n\nIf a plugin module is passed (via `--plugins`), it will be `require()`d and then invoked, being passed in the asset smasher library (the module defined in `lib/asset-smasher.js`)\n\nTo register your transformer, just add another entry to the `transforms` object.\n\nE.g.\n\n**my_plugin.js**\n\n    module.exports = function(assetSmasher) {\n       // A stupid transformer that adds \"foo\" to the start and end of the contents\n       var FooTransform = function FooTransform(options) {\n         this.options = options || {};\n       };\n       FooTransform.prototype = {\n         extensions:function () {\n           return ['.foo'];\n         },\n         shouldTransform:function (file) {\n           return path.extname(file) === '.foo';\n         },\n         transformedFileName:function (file) {\n           return path.basename(file, '.foo');\n         },\n         transform:function (asset, cb) {\n           // Transform the file name\n           asset.logicalName = this.transformedFileName(asset.logicalName);\n           // Get the contents\n           var contents = asset.contents;\n           if (Buffer.isBuffer(contents)) {\n             contents = contents.toString('utf-8');\n           }\n           // Compile the contents\n           asset.contents = 'foo-' + contents + '-foo';\n           cb();\n         }\n       };\n\n       assetSmasher.transforms.Foo = FooTransform;\n    };\n\nIf you then invoke `asset-smasher` with `--plugins my_plugin.js` it will automatically transform `*.foo` files.\n\n## <a name=\"express-middleware\"></a> Using via Express Middleware\n\nAsset smasher exposes an `express` middleware that can:\n\n- Serve your assets un-merged/mangled in development mode.\n- Serve precompiled assets (with hashed file names) in production mode.\n\nThe middleware takes in the same arguments as the `Smasher` constructor, with a few extras:\n\n- `serve` - boolean whether the middleware should serve the asset files.  Usualy set this to `true` in development, `false` in production\n- `assetMapLocation` - path to the `map.json` generated by the command-line `asset-smasher` util.  This allows the helper methods to determine what the hashed file names were\n\nThe middleware exposes two helpers to your views:\n\n- `js_asset(logicalPath)` - Render a `<script>` tag for the specified JS asset. When `serve` is true, this will \"explode\" manifests and write out a separate `<script>` for each required file.  This makes debugging much easier.\n- `css_asset(logicalPath)` - Render a `<link>` tag for the specified CSS asset.  Same thing happens when `serve` is true as with `js_asset`.\n- `raw_asset(logicalPath)` - Return the path to the asset.\n\n### Example\n\n    var assetSmasher = require('asset-smasher');\n\n**Middleware config (Dev)**\n\n    app.use(assetSmasher.middleware({\n      serve: true,\n      paths: [path.join(__dirname, 'assetDir1'), path.join(__dirname, 'assetDir2')],\n      prefix: '/assets',\n      outputTo: path.join(__dirname, 'tmp')\n    }));\n\n**Middleware config (Prod)**\n\n    app.use(assetSmasher.middleware({\n      serve: false,\n      prefix: '/assets',\n      assetMapLocation: path.join(__dirname, 'public/assets/map.json')\n    }));\n\n**View (ejs here, but could be others)**\n\n    <!DOCTYPE html>\n    <html>\n    <head>\n      <title>Test</title>\n      <%- css_asset('application.css') %>\n      <%- js_asset('application.js') %>\n    </head>\n    <body>\n      This is a test\n    </body>\n    </html>\n\n## <a name=\"programmatic-interface\"></a> Using via Programmatic Interface\n\nYou can invoke Asset Smasher programmatically by `require`ing it.  You can also plug in additional transformers this way.\n\nThe `Smasher` object has the following methods:\n\n - `compileAssets(cb)` - Find and compile all the assets.\n - `compileSingleAsset(assetFilePath, cb)` - Compile a single asset (assetFilePath is the actual path to the file, not a logical path)\n - `findAssets(cb)` - Find, but don't compile the assets.  Good for determining dependency graph without compiling.\n - `getAssetByLogicalPath(logicalPath)` - Get information about an asset by its logical path.  Only call this after finding/compiling assets.\n - `getHashedFileMapping()` - When `hash` is true, this returns a mapping of logical path to \"hashed\" logical path.  This object is what the command-line tool outputs to `map.json`. Only call this after finding/compiling assets.\n - `getRequiredLogicalPathsFor(asset)` - Get the logical paths of the assets that should be merged into the specified asset (populated for `.mf` files). Only call this after finding/compiling assets.\n - `getProcessingOrderLogicalPaths()` - Get a list of the order in which assets should be processed in order to satisfy all dependencies. Only call this after finding/compiling assets.\n - `reset()` - Reset the asset metadata.\n\nThe `Asset` object returned by `getAssetByLogicalPath` has the following properties (and one method):\n\n - `logicalPath` - The logical path\n - `hashedPath` - If `hash` is true, the hashed filename path, otherwise the same as `logicalPath`\n - `assetFilePath` - The full path to the actual source asset\n - `compiled` - Whether the asset has been compiled\n - `compiledAssetFilePath` - The full path to the compiled asset file\n - `reset()` - Set the asset back to its before-compile state (clear out contents, set name back to pre-transform name)\n\n**Example**\n\n    var assetSmasher = require('asset-smasher');\n    var Smasher = assetSmasher.Smasher;\n\n    // Plug in a custom transformer\n    assetSmasher.transforms['MyAwesomeFormat'] = require('myAwesomeFormatTransformer');\n\n    var sm = new Smasher({\n      paths:['/path/one', '/path/two'],\n      only:['**/*.{jpg,gif,png}', 'application.js.mf', 'application.css.mf'],\n      prefix:'/assets',\n      compress:true,\n      hash:true,\n      hashVersion:'1.0',\n      gzip:true,\n      outputTo:__dirname + '/public/assets',\n      helpers:{\n       my: 'helper',\n       another: 'helper'\n      }\n    });\n    sm.compileAssets(function(err) {\n      if(err) {\n        console.log('An error occurred', err);\n      } else {\n        console.log('Compilation done!');\n      }\n    });\n\n## <a name=\"transformer-notes\"></a> Transformer Notes\n\n### <a name=\"tn-less-styl\"></a> LESS/Styles\n\n- When the `compress` option is true, the compression is done directly via the `less/stylus` compilers\n- Any `@include/@import` paths are *relative to the path that the file is in*.\n- Any `@include/@import`ed files will *not* be processed individually by Asset Smasher (i.e. you can't `@include` a LESS file that is preprocessed by ejs)\n\n### <a name=\"tn-ejs\"></a> ejs\n\n- Any registered helpers will be exposed as global variables to the `ejs` transform.\n- The built-in `asset_paths` helper can be used here.\n\n### <a name=\"tn-dust-hbs\"></a> dust and Handlebars\n\n- The name of the template will be the template's \"logical path\" (minus the asset path it is in), minus the `.js.dust` or `.js.hbs` file extension.\n    - E.g. `/my/templates/test.js.dust`'s template name will be `test` (assuming `/my/templates` is the asset path)\n","_id":"asset-smasher@0.2.1","dist":{"shasum":"c190db5c252925a982e1b706d9c2ce55919dae90","tarball":"https://registry.npmjs.org/asset-smasher/-/asset-smasher-0.2.1.tgz","integrity":"sha512-jsiwN/9PSb32+fesbpXBTHzUG5H7Tklq4YPQ51+5yBLpYToUwBFyShFw0CB/X+bxfFDLGEnMf4gFerNnGUNDeg==","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIHKWjHE1BJ/1b6O9Z2TTqf+uBx3NQW+qF9RrG6ZlFSSzAiEA1nHgAXiUdBClfIWW2NLKYNropRdGDFpg/1GyINAwm3s="}]},"maintainers":[{"name":"jriecken","email":"jriecken@gmail.com"}]},"0.2.2":{"name":"asset-smasher","description":"Asset pre-processor, merger, and compressor.","version":"0.2.2","author":{"name":"Jim Riecken","email":"jriecken@gmail.com"},"keywords":["asset","compress","merge","preprocess"],"license":{"type":"MIT","url":"http://github.com/jriecken/asset-smasher/raw/master/LICENSE"},"repository":{"type":"git","url":"git://github.com/jriecken/asset-smasher.git"},"bugs":{"url":"http://github.com/jriecken/asset-smasher/issues"},"main":"./lib/asset-smasher.js","bin":{"asset-smasher":"./bin/asset-smasher"},"dependencies":{"async":"0.1.22","commander":"0.6.1","glob":"3.1.10","mkdirp":"0.3.3","minimatch":"0.2.5","uglify-js":"1.3.2","underscore":"1.3.3"},"optionalDependencies":{},"devDependencies":{},"engines":{"node":">= 0.6.0"},"readme":"# Asset Smasher\n\nAsset pre-processor, merger, and compressor for Node.js\n\n- [Structuring Your Assets](#structure-assets)\n    - [Manifest Files](#manifest-files)\n- [Using via Command Line](#command-line)\n    - [Helpers](#cli-helpers)\n    - [Plugins](#cli-plugins)\n- [Using via Express Middleware](#express-middleware)\n- [Using via Programmatic Interface](#programmatic-interface)\n- [Transformer Notes](#transformer-notes)\n    - [LESS/Stylus](#tn-less-styl)\n    - [ejs](#tn-ejs)\n    - [dust and Handlebars](#tn-dust-hbs)\n\n## Overview\n\nAsset Smasher is a command-line tool, express middleware, and programmatic interface for:\n\n- Pre-processing and transforming files down to plain JavaScript and CSS.\n    - `.coffee` - Compile CoffeeScript into JavaScript\n    - `.ejs` - Run a file through EJS (e.g. to populate configuration parameters into a JavaScript file)\n    - `.less` - Compile Less into CSS\n    - `.styl` - Compile Stylus into CSS\n    - `.hbs` - Precompile Handlebars templates into JavaScript files that register them with `Handlebars.templates`.\n    - `.dust` - Precompile Dust templates into JavaScript files that register them for use with `dust.render`.\n    - Processors can be chained together.  E.g `test.js.hbs.ejs` (run Handlebars template through EJS, then compile it)\n    - Additional processors can be plugged in.\n- Merging files together using Manifest files (`.mf`) with dependency management directives similar to Sprockets.\n    - `require` - Require a single file\n    - `require_dir` - Require all the files in a specific directory\n    - `require_tree` - Require all the files in a specific directory (and subdirectories)\n- Compressing, gzipping, and generating hashed file names.\n    - Compress JavaScript files with `uglify-js`\n    - Compress LESS during LESS preprocessing\n    - Generate Gzipped versions of files\n    - Include a MD5 hash of the file's contents in the file name. `myAsset.js` -> `myAsset-c89cba7b7df028e65cb01d86f4d27077.js`\n        - `asset_path` helper that can be used to reference the hashed name.\n\nIt's released under the [MIT](http://en.wikipedia.org/wiki/MIT_License) license.\n\n## <a name=\"structure-assets\"></a> Structuring Your Assets\n\nAsset Smasher has the concept of \"asset paths\".  These are locations in which your asset files will be located, and from which any relative asset paths will be rooted to.\n\nThe simplest structure has one asset path.\n\nE.g.\n\n    Asset Paths\n    -----------\n     - app\n\n    File Structure\n    --------------\n    app/\n      js/\n      css/\n      images/\n\nA more complicated structure might be\n\n    Asset Paths\n    -----------\n     - app\n     - lib\n     - vendor\n\n    File Structure\n    --------------\n    app/\n      js/\n      css/\n      images/\n    lib/\n      js/\n      css/\n      images/\n    vendor/\n      js/\n      css/\n      images/\n\nBoth of these examples will result in a compiled structure of\n\n    js/\n    css/\n    images/\n\n### <a name=\"manifest-files\"></a> Manifest Files\n\nManifest (`.mf`) files are used to merge many assets into a single resulting file. The file should be named with the resulting file type before the `.mf` extension (e.g. `manifest.css.mf` or `manifest.js.mf`. *Manifest files can `require` other manifest files*\n\nA simple manifest file might look like\n\n    # A comment here\n    require \"./one.js\"\n    require_dir \"./subdir1\"\n    #\n    # Another comment\n    require_tree \"./subdir2\"\n\n**Directives:**\n\n<table border=\"1\" cellpadding=\"5\" cellspacing=\"0\" width=\"100%\">\n <thead>\n  <tr><th width=\"15%\">Directive</th><th width=\"85%\">Description</th></tr>\n </thead>\n <tbody>\n  <tr>\n    <td><code>require \"[path]\"</code></td>\n    <td>\n      <strong>Include a single file</strong>\n      <ul>\n       <li>\n         If the path starts with <code>\"/\"</code>, <code>\"../\"</code>, or <code>\"./\"</code>, process and include the specified file.  The file <em>must</em> be\n         inside one of the configured asset paths.\n       </li>\n       <li>\n         If the path does not start with <code>\"/\"</code>, <code>\"../\"</code>, or <code>\"./\"</code>, the file will be searched for in all of the configured\n         asset paths.  E.g. if there are asset paths <code>one</code> and <code>two</code> defined, <code>require \"js/test.js\"</code>\n         will look for <code>one/js/test.js</code> and then <code>two/js/test.js</code> stopping when it finds a matching file.\n       </li>\n       <li>\n         The filename part of the path does not have to include the whole extension.  E.g <code>require \"test\"</code>\n         finds the first file that matches the name in the asset paths (for example <code>test.js.ejs</code>)\n       </li>\n      </ul>\n    </td>\n  </tr>\n  <tr>\n    <td><code>require_dir \"[path]\"</code></td>\n    <td>\n      <strong>Include all the files in a directory</strong>\n      <ul>\n       <li>\n         The path must be absolute, or relative to the current directory.  E.g. you can do <code>require_dir \"../some/other/dir\"</code>\n         but not <code>require_dir \"somedir\"</code>\n       </li>\n       <li>\n         If using absolute paths, or <code>\"..\"</code> in your paths, the resulting directory needs to be inside one of the configured asset paths.\n       </li>\n       <li>\n         Make sure the directory only contains assets of the type you want.  E.g. for <code>myManifest.js.mf</code>, the dir required had better\n         only contain javascript files, or else bad things will happen.\n       </li>\n      </ul>\n    </td>\n  </tr>\n  <tr>\n    <td><code>require_tree \"[path]\"</code></td>\n    <td>\n      <strong>Include the files in a directory recursively</strong>\n      <ul>\n        <li>The rules for <code>require_tree</code> are the same as the rules for <code>require_dir</code></li>\n      </ul>\n    </td>\n  </tr>\n </tbody>\n</table>\n\n## <a name=\"command-line\"></a> Using via Command-Line\n\nUse `npm install -g asset-smasher` to install the `asset-smasher` command-line tool globally.\n\n      asset-smasher --help\n\n        Usage: asset-smasher [options] <output dir>\n\n        Options:\n\n          -h, --help               output usage information\n          -V, --version            output the version number\n          --compress               compress/minify the generated files\n          --hash                   generate versions of the files with md5 hashes in the name\n          --gzip                   generate gzipped versions of the compiled files\n          --hashVersion <version>  invalidate all assets without changing file contents [1.0]\n          --only <pattern,...>     only process the files matching these glob patterns (relative to any of the paths) [**/*]\n          --paths <path,...>       list of paths to look for assets [.]\n          --prefix <prefix>        prefix to append to logical paths when constructing urls. use if output dir is not served from the root of your web app []\n          --helpers <js_file>      a .js module of helper functions require()s to expose to transforms []\n          --plugins <js_file>      a .js plugin module []\n\n        If --only is not specified, *all* files in the --paths will be processed.\n\n        Examples:\n\n          Compile all assets in the current directory to /home/me/compiledAssets\n\n            $ asset-smasher /home/me/compiledAssets\n\n          Something similar to what the Rails asset pipeline does by default\n\n            $ asset-smasher --compress --hash --gzip --prefix /assets \\\n                --paths ./js,./css,./images \\\n                --only **/*.{jpg,gif,png},application.js.mf,application.css.mf ./public/assets\n\n          Compile assets, providing some custom helpers to the transformation\n\n            $ asset-smasher --helpers helpers.js output\n\n### <a name=\"cli-helpers\"></a> Helpers\n\nThere is a built-in `asset_path` helper that can be used to get the \"real\" (i.e. with hashed file name) path of an asset.  E.g. `asset_path('css/myFile.css')` might return `'/assets/css/myFile-c89cba7b7df028e65cb01d86f4d27077.css`.\n\nSome transformers (e.g. the `.ejs` one) take in a set of local variables that they can use during transformation. You can pass in the path to a JavaScript module whose exports will be included in this set of variables.\n\nYou can use this, for example, to set configuration parameters in your JS files:\n\n**helper.js**\n\n    exports.serviceUrl = 'http://my.service/';\n\n**config.js.ejs**\n\n    //...\n    var serviceUrl = '<%= serviceUrl %>';\n    var cssLocation = '<%= asset_path('css/myFile.css') %>';\n    //...\n\n**Execution**\n\n    $ asset-smasher --helpers helper.js --only config.js.ejs,css/myFile.css .\n    $ cat config.js\n    var serviceUrl = 'http://my.service/';\n    var cssLocation = '/assets/css/myFile-c89cba7b7df028e65cb01d86f4d27077.css';\n\n\n### <a name=\"cli-plugins\"></a> Plugins\n\nIf there's a type of file you want to pre-process that is not natively supported by Asset Smasher, you can add it using a plugin file.\n\nFor an example of what the transformer classes look like, look in the `lib/compilation/transforms` directory\n\nIf a plugin module is passed (via `--plugins`), it will be `require()`d and then invoked, being passed in the asset smasher library (the module defined in `lib/asset-smasher.js`)\n\nTo register your transformer, just add another entry to the `transforms` object.\n\nE.g.\n\n**my_plugin.js**\n\n    module.exports = function(assetSmasher) {\n       // A stupid transformer that adds \"foo\" to the start and end of the contents\n       var FooTransform = function FooTransform(options) {\n         this.options = options || {};\n       };\n       FooTransform.prototype = {\n         extensions:function () {\n           return ['.foo'];\n         },\n         shouldTransform:function (file) {\n           return path.extname(file) === '.foo';\n         },\n         transformedFileName:function (file) {\n           return path.basename(file, '.foo');\n         },\n         transform:function (asset, cb) {\n           // Transform the file name\n           asset.logicalName = this.transformedFileName(asset.logicalName);\n           // Get the contents\n           var contents = asset.contents;\n           if (Buffer.isBuffer(contents)) {\n             contents = contents.toString('utf-8');\n           }\n           // Compile the contents\n           asset.contents = 'foo-' + contents + '-foo';\n           cb();\n         }\n       };\n\n       assetSmasher.transforms.Foo = FooTransform;\n    };\n\nIf you then invoke `asset-smasher` with `--plugins my_plugin.js` it will automatically transform `*.foo` files.\n\n## <a name=\"express-middleware\"></a> Using via Express Middleware\n\nAsset smasher exposes an `express` middleware that can:\n\n- Serve your assets un-merged/mangled in development mode.\n- Serve precompiled assets (with hashed file names) in production mode.\n\nThe middleware takes in the same arguments as the `Smasher` constructor, with a few extras:\n\n- `serve` - boolean whether the middleware should serve the asset files.  Usualy set this to `true` in development, `false` in production\n- `assetMapLocation` - path to the `map.json` generated by the command-line `asset-smasher` util.  This allows the helper methods to determine what the hashed file names were\n\nThe middleware exposes two helpers to your views:\n\n- `js_asset(logicalPath)` - Render a `<script>` tag for the specified JS asset. When `serve` is true, this will \"explode\" manifests and write out a separate `<script>` for each required file.  This makes debugging much easier.\n- `css_asset(logicalPath)` - Render a `<link>` tag for the specified CSS asset.  Same thing happens when `serve` is true as with `js_asset`.\n- `raw_asset(logicalPath)` - Return the path to the asset.\n\n### Example\n\n    var assetSmasher = require('asset-smasher');\n\n**Middleware config (Dev)**\n\n    app.use(assetSmasher.middleware({\n      serve: true,\n      paths: [path.join(__dirname, 'assetDir1'), path.join(__dirname, 'assetDir2')],\n      prefix: '/assets',\n      outputTo: path.join(__dirname, 'tmp')\n    }));\n\n**Middleware config (Prod)**\n\n    app.use(assetSmasher.middleware({\n      serve: false,\n      prefix: '/assets',\n      assetMapLocation: path.join(__dirname, 'public/assets/map.json')\n    }));\n\n**View (ejs here, but could be others)**\n\n    <!DOCTYPE html>\n    <html>\n    <head>\n      <title>Test</title>\n      <%- css_asset('application.css') %>\n      <%- js_asset('application.js') %>\n    </head>\n    <body>\n      This is a test\n    </body>\n    </html>\n\n## <a name=\"programmatic-interface\"></a> Using via Programmatic Interface\n\nYou can invoke Asset Smasher programmatically by `require`ing it.  You can also plug in additional transformers this way.\n\nThe `Smasher` object has the following methods:\n\n - `compileAssets(cb)` - Find and compile all the assets.\n - `compileSingleAsset(assetFilePath, cb)` - Compile a single asset (assetFilePath is the actual path to the file, not a logical path)\n - `findAssets(cb)` - Find, but don't compile the assets.  Good for determining dependency graph without compiling.\n - `getAssetByLogicalPath(logicalPath)` - Get information about an asset by its logical path.  Only call this after finding/compiling assets.\n - `getHashedFileMapping()` - When `hash` is true, this returns a mapping of logical path to \"hashed\" logical path.  This object is what the command-line tool outputs to `map.json`. Only call this after finding/compiling assets.\n - `getRequiredLogicalPathsFor(asset)` - Get the logical paths of the assets that should be merged into the specified asset (populated for `.mf` files). Only call this after finding/compiling assets.\n - `getProcessingOrderLogicalPaths()` - Get a list of the order in which assets should be processed in order to satisfy all dependencies. Only call this after finding/compiling assets.\n - `reset()` - Reset the asset metadata.\n\nThe `Asset` object returned by `getAssetByLogicalPath` has the following properties (and one method):\n\n - `logicalPath` - The logical path\n - `hashedPath` - If `hash` is true, the hashed filename path, otherwise the same as `logicalPath`\n - `assetFilePath` - The full path to the actual source asset\n - `compiled` - Whether the asset has been compiled\n - `compiledAssetFilePath` - The full path to the compiled asset file\n - `reset()` - Set the asset back to its before-compile state (clear out contents, set name back to pre-transform name)\n\n**Example**\n\n    var assetSmasher = require('asset-smasher');\n    var Smasher = assetSmasher.Smasher;\n\n    // Plug in a custom transformer\n    assetSmasher.transforms['MyAwesomeFormat'] = require('myAwesomeFormatTransformer');\n\n    var sm = new Smasher({\n      paths:['/path/one', '/path/two'],\n      only:['**/*.{jpg,gif,png}', 'application.js.mf', 'application.css.mf'],\n      prefix:'/assets',\n      compress:true,\n      hash:true,\n      hashVersion:'1.0',\n      gzip:true,\n      outputTo:__dirname + '/public/assets',\n      helpers:{\n       my: 'helper',\n       another: 'helper'\n      }\n    });\n    sm.compileAssets(function(err) {\n      if(err) {\n        console.log('An error occurred', err);\n      } else {\n        console.log('Compilation done!');\n      }\n    });\n\n## <a name=\"transformer-notes\"></a> Transformer Notes\n\n### <a name=\"tn-less-styl\"></a> LESS/Styles\n\n- When the `compress` option is true, the compression is done directly via the `less/stylus` compilers\n- Any `@include/@import` paths are *relative to the path that the file is in*.\n- Any `@include/@import`ed files will *not* be processed individually by Asset Smasher (i.e. you can't `@include` a LESS file that is preprocessed by ejs)\n\n### <a name=\"tn-ejs\"></a> ejs\n\n- Any registered helpers will be exposed as global variables to the `ejs` transform.\n- The built-in `asset_paths` helper can be used here.\n\n### <a name=\"tn-dust-hbs\"></a> dust and Handlebars\n\n- The name of the template will be the template's \"logical path\" (minus the asset path it is in), minus the `.js.dust` or `.js.hbs` file extension.\n    - E.g. `/my/templates/test.js.dust`'s template name will be `test` (assuming `/my/templates` is the asset path)\n","_id":"asset-smasher@0.2.2","dist":{"shasum":"01a8969b3533fe323b598199f4c467436358de93","tarball":"https://registry.npmjs.org/asset-smasher/-/asset-smasher-0.2.2.tgz","integrity":"sha512-luRs0ODF8858kujboqsybmfbRrl8+i3y541bTDde+e2SL+rLoWYImlprAAbMJp/76wbDAzZcC3aLV9uMbwve+A==","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIQD37w6huuSKXTwy/p8iRAx9mGHY6vuBvS6pMOfK9Lp8TwIgBju4wnlUtJhMOa0GmMLPMmg4sGFdmGhbW/19FyuILfM="}]},"_npmVersion":"1.1.63","_npmUser":{"name":"jriecken","email":"jriecken@gmail.com"},"maintainers":[{"name":"jriecken","email":"jriecken@gmail.com"}]},"0.2.3":{"name":"asset-smasher","description":"Asset pre-processor, merger, and compressor.","version":"0.2.3","author":{"name":"Jim Riecken","email":"jriecken@gmail.com"},"keywords":["asset","compress","merge","preprocess"],"license":{"type":"MIT","url":"http://github.com/jriecken/asset-smasher/raw/master/LICENSE"},"repository":{"type":"git","url":"git://github.com/jriecken/asset-smasher.git"},"bugs":{"url":"http://github.com/jriecken/asset-smasher/issues"},"main":"./lib/asset-smasher.js","bin":{"asset-smasher":"./bin/asset-smasher"},"dependencies":{"async":"0.2.6","commander":"1.1.1","glob":"3.1.21","mkdirp":"0.3.5","minimatch":"0.2.11","send":"0.1.0","uglify-js":"2.2.5","underscore":"1.4.4","ycssmin":"1.0.1"},"optionalDependencies":{},"devDependencies":{},"engines":{"node":">= 0.6.0"},"readme":"# Asset Smasher\n\nAsset pre-processor, merger, and compressor for Node.js\n\n- [Structuring Your Assets](#structure-assets)\n    - [Manifest Files](#manifest-files)\n- [Using via Command Line](#command-line)\n    - [Helpers](#cli-helpers)\n    - [Plugins](#cli-plugins)\n- [Using via Express Middleware](#express-middleware)\n- [Using via Programmatic Interface](#programmatic-interface)\n- [Transformer Notes](#transformer-notes)\n    - [LESS/Stylus](#tn-less-styl)\n    - [ejs](#tn-ejs)\n    - [dust and Handlebars](#tn-dust-hbs)\n\n## Overview\n\nAsset Smasher is a command-line tool, express middleware, and programmatic interface for:\n\n- Pre-processing and transforming files down to plain JavaScript and CSS.\n    - `.coffee` - Compile CoffeeScript into JavaScript\n    - `.ejs` - Run a file through EJS (e.g. to populate configuration parameters into a JavaScript file)\n    - `.less` - Compile Less into CSS\n    - `.styl` - Compile Stylus into CSS\n    - `.hbs` - Precompile Handlebars templates into JavaScript files that register them with `Handlebars.templates`.\n    - `.dust` - Precompile Dust templates into JavaScript files that register them for use with `dust.render`.\n    - Processors can be chained together.  E.g `test.js.hbs.ejs` (run Handlebars template through EJS, then compile it)\n    - Additional processors can be plugged in.\n- Merging files together using Manifest files (`.mf`) with dependency management directives similar to Sprockets.\n    - `require` - Require a single file\n    - `require_dir` - Require all the files in a specific directory\n    - `require_tree` - Require all the files in a specific directory (and subdirectories)\n- Compressing, gzipping, and generating hashed file names.\n    - Compress JavaScript files with `uglify-js`\n    - Compress CSS files with `ycssmin`\n    - Generate Gzipped versions of files\n    - Include a MD5 hash of the file's contents in the file name. `myAsset.js` -> `myAsset-c89cba7b7df028e65cb01d86f4d27077.js`\n        - `asset_path` helper that can be used to reference the hashed name.\n\nIt's released under the [MIT](http://en.wikipedia.org/wiki/MIT_License) license.\n\n## <a name=\"structure-assets\"></a> Structuring Your Assets\n\nAsset Smasher has the concept of \"asset paths\".  These are locations in which your asset files will be located, and from which any relative asset paths will be rooted to.\n\nThe simplest structure has one asset path.\n\nE.g.\n\n    Asset Paths\n    -----------\n     - app\n\n    File Structure\n    --------------\n    app/\n      js/\n      css/\n      images/\n\nA more complicated structure might be\n\n    Asset Paths\n    -----------\n     - app\n     - lib\n     - vendor\n\n    File Structure\n    --------------\n    app/\n      js/\n      css/\n      images/\n    lib/\n      js/\n      css/\n      images/\n    vendor/\n      js/\n      css/\n      images/\n\nBoth of these examples will result in a compiled structure of\n\n    js/\n    css/\n    images/\n\n### <a name=\"manifest-files\"></a> Manifest Files\n\nManifest (`.mf`) files are used to merge many assets into a single resulting file. The file should be named with the resulting file type before the `.mf` extension (e.g. `manifest.css.mf` or `manifest.js.mf`. *Manifest files can `require` other manifest files*\n\nA simple manifest file might look like\n\n    # A comment here\n    require \"./one.js\"\n    require_dir \"./subdir1\"\n    #\n    # Another comment\n    require_tree \"./subdir2\"\n\n**Directives:**\n\n<table border=\"1\" cellpadding=\"5\" cellspacing=\"0\" width=\"100%\">\n <thead>\n  <tr><th width=\"15%\">Directive</th><th width=\"85%\">Description</th></tr>\n </thead>\n <tbody>\n  <tr>\n    <td><code>require \"[path]\"</code></td>\n    <td>\n      <strong>Include a single file</strong>\n      <ul>\n       <li>\n         If the path starts with <code>\"/\"</code>, <code>\"../\"</code>, or <code>\"./\"</code>, process and include the specified file.  The file <em>must</em> be\n         inside one of the configured asset paths.\n       </li>\n       <li>\n         If the path does not start with <code>\"/\"</code>, <code>\"../\"</code>, or <code>\"./\"</code>, the file will be searched for in all of the configured\n         asset paths.  E.g. if there are asset paths <code>one</code> and <code>two</code> defined, <code>require \"js/test.js\"</code>\n         will look for <code>one/js/test.js</code> and then <code>two/js/test.js</code> stopping when it finds a matching file.\n       </li>\n       <li>\n         The filename part of the path does not have to include the whole extension.  E.g <code>require \"test\"</code>\n         finds the first file that matches the name in the asset paths (for example <code>test.js.ejs</code>)\n       </li>\n      </ul>\n    </td>\n  </tr>\n  <tr>\n    <td><code>require_dir \"[path]\"</code></td>\n    <td>\n      <strong>Include all the files in a directory</strong>\n      <ul>\n       <li>\n         The path must be absolute, or relative to the current directory.  E.g. you can do <code>require_dir \"../some/other/dir\"</code>\n         but not <code>require_dir \"somedir\"</code>\n       </li>\n       <li>\n         If using absolute paths, or <code>\"..\"</code> in your paths, the resulting directory needs to be inside one of the configured asset paths.\n       </li>\n       <li>\n         Make sure the directory only contains assets of the type you want.  E.g. for <code>myManifest.js.mf</code>, the dir required had better\n         only contain javascript files, or else bad things will happen.\n       </li>\n      </ul>\n    </td>\n  </tr>\n  <tr>\n    <td><code>require_tree \"[path]\"</code></td>\n    <td>\n      <strong>Include the files in a directory recursively</strong>\n      <ul>\n        <li>The rules for <code>require_tree</code> are the same as the rules for <code>require_dir</code></li>\n      </ul>\n    </td>\n  </tr>\n </tbody>\n</table>\n\n## <a name=\"command-line\"></a> Using via Command-Line\n\nUse `npm install -g asset-smasher` to install the `asset-smasher` command-line tool globally.\n\n      asset-smasher --help\n\n        Usage: asset-smasher [options] <output dir>\n\n        Options:\n\n          -h, --help               output usage information\n          -V, --version            output the version number\n          --compress               compress/minify the generated files\n          --hash                   generate versions of the files with md5 hashes in the name\n          --gzip                   generate gzipped versions of the compiled files\n          --hashVersion <version>  invalidate all assets without changing file contents [1.0]\n          --only <pattern,...>     only process the files matching these glob patterns (relative to any of the paths) [**/*]\n          --paths <path,...>       list of paths to look for assets [.]\n          --prefix <prefix>        prefix to append to logical paths when constructing urls. use if output dir is not served from the root of your web app []\n          --helpers <js_file>      a .js module of helper functions require()s to expose to transforms []\n          --plugins <js_file>      a .js plugin module []\n\n        If --only is not specified, *all* files in the --paths will be processed.\n\n        Examples:\n\n          Compile all assets in the current directory to /home/me/compiledAssets\n\n            $ asset-smasher /home/me/compiledAssets\n\n          Something similar to what the Rails asset pipeline does by default\n\n            $ asset-smasher --compress --hash --gzip --prefix /assets \\\n                --paths ./js,./css,./images \\\n                --only **/*.{jpg,gif,png},application.js.mf,application.css.mf ./public/assets\n\n          Compile assets, providing some custom helpers to the transformation\n\n            $ asset-smasher --helpers helpers.js output\n\n### <a name=\"cli-helpers\"></a> Helpers\n\nThere is a built-in `asset_path` helper that can be used to get the \"real\" (i.e. with hashed file name) path of an asset.  E.g. `asset_path('css/myFile.css')` might return `'/assets/css/myFile-c89cba7b7df028e65cb01d86f4d27077.css`.\n\nSome transformers (e.g. the `.ejs` one) take in a set of local variables that they can use during transformation. You can pass in the path to a JavaScript module whose exports will be included in this set of variables.\n\nYou can use this, for example, to set configuration parameters in your JS files:\n\n**helper.js**\n\n    exports.serviceUrl = 'http://my.service/';\n\n**config.js.ejs**\n\n    //...\n    var serviceUrl = '<%= serviceUrl %>';\n    var cssLocation = '<%= asset_path('css/myFile.css') %>';\n    //...\n\n**Execution**\n\n    $ asset-smasher --helpers helper.js --only config.js.ejs,css/myFile.css .\n    $ cat config.js\n    var serviceUrl = 'http://my.service/';\n    var cssLocation = '/assets/css/myFile-c89cba7b7df028e65cb01d86f4d27077.css';\n\n\n### <a name=\"cli-plugins\"></a> Plugins\n\nIf there's a type of file you want to pre-process that is not natively supported by Asset Smasher, you can add it using a plugin file.\n\nFor an example of what the transformer classes look like, look in the `lib/compilation/transforms` directory\n\nIf a plugin module is passed (via `--plugins`), it will be `require()`d and then invoked, being passed in the asset smasher library (the module defined in `lib/asset-smasher.js`)\n\nTo register your transformer, just add another entry to the `transforms` object.\n\nE.g.\n\n**my_plugin.js**\n\n    module.exports = function(assetSmasher) {\n       // A stupid transformer that adds \"foo\" to the start and end of the contents\n       var FooTransform = function FooTransform(options) {\n         this.options = options || {};\n       };\n       FooTransform.prototype = {\n         extensions:function () {\n           return ['.foo'];\n         },\n         shouldTransform:function (file) {\n           return path.extname(file) === '.foo';\n         },\n         transformedFileName:function (file) {\n           return path.basename(file, '.foo');\n         },\n         transform:function (asset, cb) {\n           // Transform the file name\n           asset.logicalName = this.transformedFileName(asset.logicalName);\n           // Get the contents\n           var contents = asset.contents;\n           if (Buffer.isBuffer(contents)) {\n             contents = contents.toString('utf-8');\n           }\n           // Compile the contents\n           asset.contents = 'foo-' + contents + '-foo';\n           cb();\n         }\n       };\n\n       assetSmasher.transforms.Foo = FooTransform;\n    };\n\nIf you then invoke `asset-smasher` with `--plugins my_plugin.js` it will automatically transform `*.foo` files.\n\n## <a name=\"express-middleware\"></a> Using via Express Middleware\n\nAsset smasher exposes an `express` middleware that can:\n\n- Serve your assets un-merged/mangled in development mode.\n- Serve precompiled assets (with hashed file names) in production mode.\n\nThe middleware takes in the same arguments as the `Smasher` constructor, with a few extras:\n\n- `serve` - boolean whether the middleware should serve the asset files.  Usualy set this to `true` in development, `false` in production\n- `assetMapLocation` - path to the `map.json` generated by the command-line `asset-smasher` util.  This allows the helper methods to determine what the hashed file names were\n\nThe middleware exposes two helpers to your views:\n\n- `js_asset(logicalPath)` - Render a `<script>` tag for the specified JS asset. When `serve` is true, this will \"explode\" manifests and write out a separate `<script>` for each required file.  This makes debugging much easier.\n- `css_asset(logicalPath)` - Render a `<link>` tag for the specified CSS asset.  Same thing happens when `serve` is true as with `js_asset`.\n- `raw_asset(logicalPath)` - Return the path to the asset.\n\n### Example\n\n    var assetSmasher = require('asset-smasher');\n\n**Middleware config (Dev)**\n\n    app.use(assetSmasher.middleware({\n      serve: true,\n      paths: [path.join(__dirname, 'assetDir1'), path.join(__dirname, 'assetDir2')],\n      prefix: '/assets',\n      outputTo: path.join(__dirname, 'tmp')\n    }));\n\n**Middleware config (Prod)**\n\n    app.use(assetSmasher.middleware({\n      serve: false,\n      prefix: '/assets',\n      assetMapLocation: path.join(__dirname, 'public/assets/map.json')\n    }));\n\n**View (ejs here, but could be others)**\n\n    <!DOCTYPE html>\n    <html>\n    <head>\n      <title>Test</title>\n      <%- css_asset('application.css') %>\n      <%- js_asset('application.js') %>\n    </head>\n    <body>\n      This is a test\n    </body>\n    </html>\n\n## <a name=\"programmatic-interface\"></a> Using via Programmatic Interface\n\nYou can invoke Asset Smasher programmatically by `require`ing it.  You can also plug in additional transformers this way.\n\nThe `Smasher` object has the following methods:\n\n - `compileAssets(cb)` - Find and compile all the assets.\n - `compileSingleAsset(assetFilePath, cb)` - Compile a single asset (assetFilePath is the actual path to the file, not a logical path)\n - `findAssets(cb)` - Find, but don't compile the assets.  Good for determining dependency graph without compiling.\n - `getAssetByLogicalPath(logicalPath)` - Get information about an asset by its logical path.  Only call this after finding/compiling assets.\n - `getHashedFileMapping()` - When `hash` is true, this returns a mapping of logical path to \"hashed\" logical path.  This object is what the command-line tool outputs to `map.json`. Only call this after finding/compiling assets.\n - `getRequiredLogicalPathsFor(asset)` - Get the logical paths of the assets that should be merged into the specified asset (populated for `.mf` files). Only call this after finding/compiling assets.\n - `getProcessingOrderLogicalPaths()` - Get a list of the order in which assets should be processed in order to satisfy all dependencies. Only call this after finding/compiling assets.\n - `reset()` - Reset the asset metadata.\n\nThe `Asset` object returned by `getAssetByLogicalPath` has the following properties (and one method):\n\n - `logicalPath` - The logical path\n - `hashedPath` - If `hash` is true, the hashed filename path, otherwise the same as `logicalPath`\n - `assetFilePath` - The full path to the actual source asset\n - `compiled` - Whether the asset has been compiled\n - `compiledAssetFilePath` - The full path to the compiled asset file\n - `reset()` - Set the asset back to its before-compile state (clear out contents, set name back to pre-transform name)\n\n**Example**\n\n    var assetSmasher = require('asset-smasher');\n    var Smasher = assetSmasher.Smasher;\n\n    // Plug in a custom transformer\n    assetSmasher.transforms['MyAwesomeFormat'] = require('myAwesomeFormatTransformer');\n\n    var sm = new Smasher({\n      paths:['/path/one', '/path/two'],\n      only:['**/*.{jpg,gif,png}', 'application.js.mf', 'application.css.mf'],\n      prefix:'/assets',\n      compress:true,\n      hash:true,\n      hashVersion:'1.0',\n      gzip:true,\n      outputTo:__dirname + '/public/assets',\n      helpers:{\n       my: 'helper',\n       another: 'helper'\n      }\n    });\n    sm.compileAssets(function(err) {\n      if(err) {\n        console.log('An error occurred', err);\n      } else {\n        console.log('Compilation done!');\n      }\n    });\n\n## <a name=\"transformer-notes\"></a> Transformer Notes\n\n### <a name=\"tn-less-styl\"></a> LESS/Styles\n\n- Any `@include/@import` paths are *relative to the path that the file is in*.\n- Any `@include/@import`ed files will *not* be processed individually by Asset Smasher (i.e. you can't `@include` a LESS file that is preprocessed by ejs)\n\n### <a name=\"tn-ejs\"></a> ejs\n\n- Any registered helpers will be exposed as global variables to the `ejs` transform.\n- The built-in `asset_paths` helper can be used here.\n\n### <a name=\"tn-dust-hbs\"></a> dust and Handlebars\n\n- The name of the template will be the template's \"logical path\" (minus the asset path it is in), minus the `.js.dust` or `.js.hbs` file extension.\n    - E.g. `/my/templates/test.js.dust`'s template name will be `test` (assuming `/my/templates` is the asset path)\n","readmeFilename":"README.md","_id":"asset-smasher@0.2.3","dist":{"shasum":"14d96e4cc3c20d7a5d922c3623344c274fe51107","tarball":"https://registry.npmjs.org/asset-smasher/-/asset-smasher-0.2.3.tgz","integrity":"sha512-AFuvgXMfVg8dLDZvXTrmZPAg/X1v6jsiiIe/tPbQ7W2kjUC1pK8Bsetl8aKWs9DqsZevGtR1l/VQTuzojO22Hw==","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIF1oYchRSNXKWDj3OYxL601uNYGHWdYN34LYhEdlwErvAiEAwUcKce+IYfjLtARi7HHCVMm0PP70Kxejp4kV6A3GO8o="}]},"_from":".","_npmVersion":"1.2.11","_npmUser":{"name":"jriecken","email":"jriecken@gmail.com"},"maintainers":[{"name":"jriecken","email":"jriecken@gmail.com"}]},"0.2.4":{"name":"asset-smasher","description":"Asset pre-processor, merger, and compressor.","version":"0.2.4","author":{"name":"Jim Riecken","email":"jriecken@gmail.com"},"keywords":["asset","compress","merge","preprocess"],"license":{"type":"MIT","url":"http://github.com/jriecken/asset-smasher/raw/master/LICENSE"},"repository":{"type":"git","url":"git://github.com/jriecken/asset-smasher.git"},"bugs":{"url":"http://github.com/jriecken/asset-smasher/issues"},"main":"./lib/asset-smasher.js","bin":{"asset-smasher":"./bin/asset-smasher"},"dependencies":{"async":"0.2.6","commander":"1.1.1","glob":"3.1.21","mkdirp":"0.3.5","minimatch":"0.2.11","send":"0.1.0","uglify-js":"2.2.5","underscore":"1.4.4","ycssmin":"1.0.1"},"optionalDependencies":{},"devDependencies":{},"engines":{"node":">= 0.6.0"},"readme":"# Asset Smasher\n\nAsset pre-processor, merger, and compressor for Node.js\n\n- [Structuring Your Assets](#structure-assets)\n    - [Manifest Files](#manifest-files)\n- [Using via Command Line](#command-line)\n    - [Helpers](#cli-helpers)\n    - [Plugins](#cli-plugins)\n- [Using via Express Middleware](#express-middleware)\n- [Using via Programmatic Interface](#programmatic-interface)\n- [Transformer Notes](#transformer-notes)\n    - [LESS/Stylus](#tn-less-styl)\n    - [ejs](#tn-ejs)\n    - [dust and Handlebars](#tn-dust-hbs)\n\n## Overview\n\nAsset Smasher is a command-line tool, express middleware, and programmatic interface for:\n\n- Pre-processing and transforming files down to plain JavaScript and CSS.\n    - `.coffee` - Compile CoffeeScript into JavaScript\n    - `.ejs` - Run a file through EJS (e.g. to populate configuration parameters into a JavaScript file)\n    - `.less` - Compile Less into CSS\n    - `.styl` - Compile Stylus into CSS\n    - `.hbs` - Precompile Handlebars templates into JavaScript files that register them with `Handlebars.templates`.\n    - `.dust` - Precompile Dust templates into JavaScript files that register them for use with `dust.render`.\n    - Processors can be chained together.  E.g `test.js.hbs.ejs` (run Handlebars template through EJS, then compile it)\n    - Additional processors can be plugged in.\n- Merging files together using Manifest files (`.mf`) with dependency management directives similar to Sprockets.\n    - `require` - Require a single file\n    - `require_dir` - Require all the files in a specific directory\n    - `require_tree` - Require all the files in a specific directory (and subdirectories)\n- Compressing, gzipping, and generating hashed file names.\n    - Compress JavaScript files with `uglify-js`\n    - Compress CSS files with `ycssmin`\n    - Generate Gzipped versions of files\n    - Include a MD5 hash of the file's contents in the file name. `myAsset.js` -> `myAsset-c89cba7b7df028e65cb01d86f4d27077.js`\n        - `asset_path` helper that can be used to reference the hashed name.\n\nIt's released under the [MIT](http://en.wikipedia.org/wiki/MIT_License) license.\n\n## <a name=\"structure-assets\"></a> Structuring Your Assets\n\nAsset Smasher has the concept of \"asset paths\".  These are locations in which your asset files will be located, and from which any relative asset paths will be rooted to.\n\nThe simplest structure has one asset path.\n\nE.g.\n\n    Asset Paths\n    -----------\n     - app\n\n    File Structure\n    --------------\n    app/\n      js/\n      css/\n      images/\n\nA more complicated structure might be\n\n    Asset Paths\n    -----------\n     - app\n     - lib\n     - vendor\n\n    File Structure\n    --------------\n    app/\n      js/\n      css/\n      images/\n    lib/\n      js/\n      css/\n      images/\n    vendor/\n      js/\n      css/\n      images/\n\nBoth of these examples will result in a compiled structure of\n\n    js/\n    css/\n    images/\n\n### <a name=\"manifest-files\"></a> Manifest Files\n\nManifest (`.mf`) files are used to merge many assets into a single resulting file. The file should be named with the resulting file type before the `.mf` extension (e.g. `manifest.css.mf` or `manifest.js.mf`. *Manifest files can `require` other manifest files*\n\nA simple manifest file might look like\n\n    # A comment here\n    require \"./one.js\"\n    require_dir \"./subdir1\"\n    #\n    # Another comment\n    require_tree \"./subdir2\"\n\n**Directives:**\n\n<table border=\"1\" cellpadding=\"5\" cellspacing=\"0\" width=\"100%\">\n <thead>\n  <tr><th width=\"15%\">Directive</th><th width=\"85%\">Description</th></tr>\n </thead>\n <tbody>\n  <tr>\n    <td><code>require \"[path]\"</code></td>\n    <td>\n      <strong>Include a single file</strong>\n      <ul>\n       <li>\n         If the path starts with <code>\"/\"</code>, <code>\"../\"</code>, or <code>\"./\"</code>, process and include the specified file.  The file <em>must</em> be\n         inside one of the configured asset paths.\n       </li>\n       <li>\n         If the path does not start with <code>\"/\"</code>, <code>\"../\"</code>, or <code>\"./\"</code>, the file will be searched for in all of the configured\n         asset paths.  E.g. if there are asset paths <code>one</code> and <code>two</code> defined, <code>require \"js/test.js\"</code>\n         will look for <code>one/js/test.js</code> and then <code>two/js/test.js</code> stopping when it finds a matching file.\n       </li>\n       <li>\n         The filename part of the path does not have to include the whole extension.  E.g <code>require \"test\"</code>\n         finds the first file that matches the name in the asset paths (for example <code>test.js.ejs</code>)\n       </li>\n      </ul>\n    </td>\n  </tr>\n  <tr>\n    <td><code>require_dir \"[path]\"</code></td>\n    <td>\n      <strong>Include all the files in a directory</strong>\n      <ul>\n       <li>\n         The path must be absolute, or relative to the current directory.  E.g. you can do <code>require_dir \"../some/other/dir\"</code>\n         but not <code>require_dir \"somedir\"</code>\n       </li>\n       <li>\n         If using absolute paths, or <code>\"..\"</code> in your paths, the resulting directory needs to be inside one of the configured asset paths.\n       </li>\n       <li>\n         Make sure the directory only contains assets of the type you want.  E.g. for <code>myManifest.js.mf</code>, the dir required had better\n         only contain javascript files, or else bad things will happen.\n       </li>\n      </ul>\n    </td>\n  </tr>\n  <tr>\n    <td><code>require_tree \"[path]\"</code></td>\n    <td>\n      <strong>Include the files in a directory recursively</strong>\n      <ul>\n        <li>The rules for <code>require_tree</code> are the same as the rules for <code>require_dir</code></li>\n      </ul>\n    </td>\n  </tr>\n </tbody>\n</table>\n\n## <a name=\"command-line\"></a> Using via Command-Line\n\nUse `npm install -g asset-smasher` to install the `asset-smasher` command-line tool globally.\n\n      asset-smasher --help\n\n        Usage: asset-smasher [options] <output dir>\n\n        Options:\n\n          -h, --help               output usage information\n          -V, --version            output the version number\n          --compress               compress/minify the generated files\n          --hash                   generate versions of the files with md5 hashes in the name\n          --gzip                   generate gzipped versions of the compiled files\n          --hashVersion <version>  invalidate all assets without changing file contents [1.0]\n          --only <pattern,...>     only process the files matching these glob patterns (relative to any of the paths) [**/*]\n          --paths <path,...>       list of paths to look for assets [.]\n          --prefix <prefix>        prefix to append to logical paths when constructing urls. use if output dir is not served from the root of your web app []\n          --helpers <js_file>      a .js module of helper functions require()s to expose to transforms []\n          --plugins <js_file>      a .js plugin module []\n\n        If --only is not specified, *all* files in the --paths will be processed.\n\n        Examples:\n\n          Compile all assets in the current directory to /home/me/compiledAssets\n\n            $ asset-smasher /home/me/compiledAssets\n\n          Something similar to what the Rails asset pipeline does by default\n\n            $ asset-smasher --compress --hash --gzip --prefix /assets \\\n                --paths ./js,./css,./images \\\n                --only **/*.{jpg,gif,png},application.js.mf,application.css.mf ./public/assets\n\n          Compile assets, providing some custom helpers to the transformation\n\n            $ asset-smasher --helpers helpers.js output\n\n### <a name=\"cli-helpers\"></a> Helpers\n\nThere is a built-in `asset_path` helper that can be used to get the \"real\" (i.e. with hashed file name) path of an asset.  E.g. `asset_path('css/myFile.css')` might return `'/assets/css/myFile-c89cba7b7df028e65cb01d86f4d27077.css`.\n\nSome transformers (e.g. the `.ejs` one) take in a set of local variables that they can use during transformation. You can pass in the path to a JavaScript module whose exports will be included in this set of variables.\n\nYou can use this, for example, to set configuration parameters in your JS files:\n\n**helper.js**\n\n    exports.serviceUrl = 'http://my.service/';\n\n**config.js.ejs**\n\n    //...\n    var serviceUrl = '<%= serviceUrl %>';\n    var cssLocation = '<%= asset_path('css/myFile.css') %>';\n    //...\n\n**Execution**\n\n    $ asset-smasher --helpers helper.js --only config.js.ejs,css/myFile.css .\n    $ cat config.js\n    var serviceUrl = 'http://my.service/';\n    var cssLocation = '/assets/css/myFile-c89cba7b7df028e65cb01d86f4d27077.css';\n\n\n### <a name=\"cli-plugins\"></a> Plugins\n\nIf there's a type of file you want to pre-process that is not natively supported by Asset Smasher, you can add it using a plugin file.\n\nFor an example of what the transformer classes look like, look in the `lib/compilation/transforms` directory\n\nIf a plugin module is passed (via `--plugins`), it will be `require()`d and then invoked, being passed in the asset smasher library (the module defined in `lib/asset-smasher.js`)\n\nTo register your transformer, just add another entry to the `transforms` object.\n\nE.g.\n\n**my_plugin.js**\n\n    module.exports = function(assetSmasher) {\n       // A stupid transformer that adds \"foo\" to the start and end of the contents\n       var FooTransform = function FooTransform(options) {\n         this.options = options || {};\n       };\n       FooTransform.prototype = {\n         extensions:function () {\n           return ['.foo'];\n         },\n         shouldTransform:function (file) {\n           return path.extname(file) === '.foo';\n         },\n         transformedFileName:function (file) {\n           return path.basename(file, '.foo');\n         },\n         transform:function (asset, cb) {\n           // Transform the file name\n           asset.logicalName = this.transformedFileName(asset.logicalName);\n           // Get the contents\n           var contents = asset.contents;\n           if (Buffer.isBuffer(contents)) {\n             contents = contents.toString('utf-8');\n           }\n           // Compile the contents\n           asset.contents = 'foo-' + contents + '-foo';\n           cb();\n         }\n       };\n\n       assetSmasher.transforms.Foo = FooTransform;\n    };\n\nIf you then invoke `asset-smasher` with `--plugins my_plugin.js` it will automatically transform `*.foo` files.\n\n## <a name=\"express-middleware\"></a> Using via Express Middleware\n\nAsset smasher exposes an `express` middleware that can:\n\n- Serve your assets un-merged/mangled in development mode.\n- Serve precompiled assets (with hashed file names) in production mode.\n\nThe middleware takes in the same arguments as the `Smasher` constructor, with a few extras:\n\n- `serve` - boolean (or object - see more below) indiacating whether the middleware should serve the asset files.  Usualy set this to `true` in development, `false` in production (e.g if you're using precompiled assets)\n    - An object can be passed in with the following properties to control the serving behavior. If `true` is passed in, the default values here will be used\n        - `individual` - Whether the individual (`true`) or merged files (`false`) should be served. Default `true`.\n- `assetMapLocation` - path to the `map.json` generated by the command-line `asset-smasher` util.  This allows the helper methods to determine what the hashed file names were\n\nThe middleware exposes two helpers to your views:\n\n- `js_asset(logicalPath)` - Render a `<script>` tag for the specified JS asset. When `serve` is true, this will \"explode\" manifests and write out a separate `<script>` for each required file.  This makes debugging much easier.\n- `css_asset(logicalPath)` - Render a `<link>` tag for the specified CSS asset.  Same thing happens when `serve` is true as with `js_asset`.\n- `raw_asset(logicalPath)` - Return the path to the asset.\n\n### Example\n\n    var assetSmasher = require('asset-smasher');\n\n**Middleware config (Dev)**\n\n    app.use(assetSmasher.middleware({\n      serve: true,\n      paths: [path.join(__dirname, 'assetDir1'), path.join(__dirname, 'assetDir2')],\n      prefix: '/assets',\n      outputTo: path.join(__dirname, 'tmp')\n    }));\n\n**Middleware config (Prod)**\n\n    app.use(assetSmasher.middleware({\n      serve: false,\n      prefix: '/assets',\n      assetMapLocation: path.join(__dirname, 'public/assets/map.json')\n    }));\n\n**Middleware config (Alternate Prod config not using precompilation, but instead compile on first access)**\n\nNote that if you use this configuration, you will **not** be able to use \"hashed\" filenames.\n\n    app.use(express.staticCache());\n    app.use(express.static(path.join(__dirname, 'public')));\n    app.use(assetSmasher.middleware({\n      serve: {\n        individual: false\n      },\n      paths: [path.join(__dirname, 'assetDir1'), path.join(__dirname, 'assetDir2')],\n      compress: true,\n      prefix: '/assets',\n      // This will make the files be served once by asset smasher\n      // and then by the express \"static\" middleware thereafter.\n      // You can then also use something like \"staticCache\" to cache the files if you're not\n      // using a reverse proxy cache on the public dir\n      outputTo: path.join(__dirname, 'public/assets')\n    }));\n\n**View (ejs here, but could be others)**\n\n    <!DOCTYPE html>\n    <html>\n    <head>\n      <title>Test</title>\n      <%- css_asset('application.css') %>\n      <%- js_asset('application.js') %>\n    </head>\n    <body>\n      This is a test\n    </body>\n    </html>\n\n## <a name=\"programmatic-interface\"></a> Using via Programmatic Interface\n\nYou can invoke Asset Smasher programmatically by `require`ing it.  You can also plug in additional transformers this way.\n\nThe `Smasher` object has the following methods:\n\n - `compileAssets(cb)` - Find and compile all the assets.\n - `compileSingleAsset(assetFilePath, cb)` - Compile a single asset (assetFilePath is the actual path to the file, not a logical path)\n - `findAssets(cb)` - Find, but don't compile the assets.  Good for determining dependency graph without compiling.\n - `getAssetByLogicalPath(logicalPath)` - Get information about an asset by its logical path.  Only call this after finding/compiling assets.\n - `getHashedFileMapping()` - When `hash` is true, this returns a mapping of logical path to \"hashed\" logical path.  This object is what the command-line tool outputs to `map.json`. Only call this after finding/compiling assets.\n - `getRequiredLogicalPathsFor(asset)` - Get the logical paths of the assets that should be merged into the specified asset (populated for `.mf` files). Only call this after finding/compiling assets.\n - `getProcessingOrderLogicalPaths()` - Get a list of the order in which assets should be processed in order to satisfy all dependencies. Only call this after finding/compiling assets.\n - `reset()` - Reset the asset metadata.\n\nThe `Asset` object returned by `getAssetByLogicalPath` has the following properties (and one method):\n\n - `logicalPath` - The logical path\n - `hashedPath` - If `hash` is true, the hashed filename path, otherwise the same as `logicalPath`\n - `assetFilePath` - The full path to the actual source asset\n - `compiled` - Whether the asset has been compiled\n - `compiledAssetFilePath` - The full path to the compiled asset file\n - `reset()` - Set the asset back to its before-compile state (clear out contents, set name back to pre-transform name)\n\n**Example**\n\n    var assetSmasher = require('asset-smasher');\n    var Smasher = assetSmasher.Smasher;\n\n    // Plug in a custom transformer\n    assetSmasher.transforms['MyAwesomeFormat'] = require('myAwesomeFormatTransformer');\n\n    var sm = new Smasher({\n      paths:['/path/one', '/path/two'],\n      only:['**/*.{jpg,gif,png}', 'application.js.mf', 'application.css.mf'],\n      prefix:'/assets',\n      compress:true,\n      hash:true,\n      hashVersion:'1.0',\n      gzip:true,\n      outputTo:__dirname + '/public/assets',\n      helpers:{\n       my: 'helper',\n       another: 'helper'\n      }\n    });\n    sm.compileAssets(function(err) {\n      if(err) {\n        console.log('An error occurred', err);\n      } else {\n        console.log('Compilation done!');\n      }\n    });\n\n## <a name=\"transformer-notes\"></a> Transformer Notes\n\n### <a name=\"tn-less-styl\"></a> LESS/Styles\n\n- Any `@include/@import` paths are *relative to the path that the file is in*.\n- Any `@include/@import`ed files will *not* be processed individually by Asset Smasher (i.e. you can't `@include` a LESS file that is preprocessed by ejs)\n\n### <a name=\"tn-ejs\"></a> ejs\n\n- Any registered helpers will be exposed as global variables to the `ejs` transform.\n- The built-in `asset_paths` helper can be used here.\n\n### <a name=\"tn-dust-hbs\"></a> dust and Handlebars\n\n- The name of the template will be the template's \"logical path\" (minus the asset path it is in), minus the `.js.dust` or `.js.hbs` file extension.\n    - E.g. `/my/templates/test.js.dust`'s template name will be `test` (assuming `/my/templates` is the asset path)\n","readmeFilename":"README.md","_id":"asset-smasher@0.2.4","dist":{"shasum":"bcfa7f926d18557a3c68febbd91f40cc1bb66100","tarball":"https://registry.npmjs.org/asset-smasher/-/asset-smasher-0.2.4.tgz","integrity":"sha512-i/LNaNWmVBownPgzM5etG2s/M7P/r2H4ejW/bGp9BMEFHQ6K37rxQ6/ilQ71/KXRxylA8uuIKBbvENRssjIuDg==","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEQCIAEV3m4Y1uzbLqy55huQuk9urQgdFCxCJ/i/KkA/Nl8rAiA4PV/sMqKEQXwsxIsyDBdfx7MyqaHe5Vlkomydx3LCgw=="}]},"_from":".","_npmVersion":"1.2.11","_npmUser":{"name":"jriecken","email":"jriecken@gmail.com"},"maintainers":[{"name":"jriecken","email":"jriecken@gmail.com"}]},"0.2.5":{"name":"asset-smasher","description":"Asset pre-processor, merger, and compressor.","version":"0.2.5","author":{"name":"Jim Riecken","email":"jriecken@gmail.com"},"keywords":["asset","compress","merge","preprocess"],"license":{"type":"MIT","url":"http://github.com/jriecken/asset-smasher/raw/master/LICENSE"},"repository":{"type":"git","url":"git://github.com/jriecken/asset-smasher.git"},"bugs":{"url":"http://github.com/jriecken/asset-smasher/issues"},"main":"./lib/asset-smasher.js","bin":{"asset-smasher":"./bin/asset-smasher"},"dependencies":{"async":"0.2.6","commander":"1.1.1","glob":"3.1.21","mkdirp":"0.3.5","minimatch":"0.2.11","send":"0.1.0","uglify-js":"2.2.5","underscore":"1.4.4","ycssmin":"1.0.1"},"optionalDependencies":{},"devDependencies":{},"engines":{"node":">= 0.6.0"},"readme":"# Asset Smasher\n\nAsset pre-processor, merger, and compressor for Node.js\n\n- [Structuring Your Assets](#structure-assets)\n    - [Manifest Files](#manifest-files)\n- [Using via Command Line](#command-line)\n    - [Helpers](#cli-helpers)\n    - [Plugins](#cli-plugins)\n- [Using via Express Middleware](#express-middleware)\n- [Using via Programmatic Interface](#programmatic-interface)\n- [Transformer Notes](#transformer-notes)\n    - [LESS/Stylus](#tn-less-styl)\n    - [ejs](#tn-ejs)\n    - [dust and Handlebars](#tn-dust-hbs)\n\n## Overview\n\nAsset Smasher is a command-line tool, express middleware, and programmatic interface for:\n\n- Pre-processing and transforming files down to plain JavaScript and CSS.\n    - `.coffee` - Compile CoffeeScript into JavaScript\n    - `.ejs` - Run a file through EJS (e.g. to populate configuration parameters into a JavaScript file)\n    - `.less` - Compile Less into CSS\n    - `.styl` - Compile Stylus into CSS\n    - `.hbs` - Precompile Handlebars templates into JavaScript files that register them with `Handlebars.templates`.\n    - `.dust` - Precompile Dust templates into JavaScript files that register them for use with `dust.render`.\n    - Processors can be chained together.  E.g `test.js.hbs.ejs` (run Handlebars template through EJS, then compile it)\n    - Additional processors can be plugged in.\n- Merging files together using Manifest files (`.mf`) with dependency management directives similar to Sprockets.\n    - `require` - Require a single file\n    - `require_dir` - Require all the files in a specific directory\n    - `require_tree` - Require all the files in a specific directory (and subdirectories)\n- Compressing, gzipping, and generating hashed file names.\n    - Compress JavaScript files with `uglify-js`\n    - Compress CSS files with `ycssmin`\n    - Generate Gzipped versions of files\n    - Include a MD5 hash of the file's contents in the file name. `myAsset.js` -> `myAsset-c89cba7b7df028e65cb01d86f4d27077.js`\n        - `asset_path` helper that can be used to reference the hashed name.\n\nIt's released under the [MIT](http://en.wikipedia.org/wiki/MIT_License) license.\n\n## <a name=\"structure-assets\"></a> Structuring Your Assets\n\nAsset Smasher has the concept of \"asset paths\".  These are locations in which your asset files will be located, and from which any relative asset paths will be rooted to.\n\nThe simplest structure has one asset path.\n\nE.g.\n\n    Asset Paths\n    -----------\n     - app\n\n    File Structure\n    --------------\n    app/\n      js/\n      css/\n      images/\n\nA more complicated structure might be\n\n    Asset Paths\n    -----------\n     - app\n     - lib\n     - vendor\n\n    File Structure\n    --------------\n    app/\n      js/\n      css/\n      images/\n    lib/\n      js/\n      css/\n      images/\n    vendor/\n      js/\n      css/\n      images/\n\nBoth of these examples will result in a compiled structure of\n\n    js/\n    css/\n    images/\n\n### <a name=\"manifest-files\"></a> Manifest Files\n\nManifest (`.mf`) files are used to merge many assets into a single resulting file. The file should be named with the resulting file type before the `.mf` extension (e.g. `manifest.css.mf` or `manifest.js.mf`. *Manifest files can `require` other manifest files*\n\nA simple manifest file might look like\n\n    # A comment here\n    require \"./one.js\"\n    require_dir \"./subdir1\"\n    #\n    # Another comment\n    require_tree \"./subdir2\"\n\n**Directives:**\n\n<table border=\"1\" cellpadding=\"5\" cellspacing=\"0\" width=\"100%\">\n <thead>\n  <tr><th width=\"15%\">Directive</th><th width=\"85%\">Description</th></tr>\n </thead>\n <tbody>\n  <tr>\n    <td><code>require \"[path]\"</code></td>\n    <td>\n      <strong>Include a single file</strong>\n      <ul>\n       <li>\n         If the path starts with <code>\"/\"</code>, <code>\"../\"</code>, or <code>\"./\"</code>, process and include the specified file.  The file <em>must</em> be\n         inside one of the configured asset paths.\n       </li>\n       <li>\n         If the path does not start with <code>\"/\"</code>, <code>\"../\"</code>, or <code>\"./\"</code>, the file will be searched for in all of the configured\n         asset paths.  E.g. if there are asset paths <code>one</code> and <code>two</code> defined, <code>require \"js/test.js\"</code>\n         will look for <code>one/js/test.js</code> and then <code>two/js/test.js</code> stopping when it finds a matching file.\n       </li>\n       <li>\n         The filename part of the path does not have to include the whole extension.  E.g <code>require \"test\"</code>\n         finds the first file that matches the name in the asset paths (for example <code>test.js.ejs</code>)\n       </li>\n      </ul>\n    </td>\n  </tr>\n  <tr>\n    <td><code>require_dir \"[path]\"</code></td>\n    <td>\n      <strong>Include all the files in a directory</strong>\n      <ul>\n       <li>\n         The path must be absolute, or relative to the current directory.  E.g. you can do <code>require_dir \"../some/other/dir\"</code>\n         but not <code>require_dir \"somedir\"</code>\n       </li>\n       <li>\n         If using absolute paths, or <code>\"..\"</code> in your paths, the resulting directory needs to be inside one of the configured asset paths.\n       </li>\n       <li>\n         Make sure the directory only contains assets of the type you want.  E.g. for <code>myManifest.js.mf</code>, the dir required had better\n         only contain javascript files, or else bad things will happen.\n       </li>\n      </ul>\n    </td>\n  </tr>\n  <tr>\n    <td><code>require_tree \"[path]\"</code></td>\n    <td>\n      <strong>Include the files in a directory recursively</strong>\n      <ul>\n        <li>The rules for <code>require_tree</code> are the same as the rules for <code>require_dir</code></li>\n      </ul>\n    </td>\n  </tr>\n </tbody>\n</table>\n\n## <a name=\"command-line\"></a> Using via Command-Line\n\nUse `npm install -g asset-smasher` to install the `asset-smasher` command-line tool globally.\n\n      asset-smasher --help\n\n        Usage: asset-smasher [options] <output dir>\n\n        Options:\n\n          -h, --help               output usage information\n          -V, --version            output the version number\n          --compress               compress/minify the generated files\n          --hash                   generate versions of the files with md5 hashes in the name\n          --gzip                   generate gzipped versions of the compiled files\n          --hashVersion <version>  invalidate all assets without changing file contents [1.0]\n          --only <pattern,...>     only process the files matching these glob patterns (relative to any of the paths) [**/*]\n          --paths <path,...>       list of paths to look for assets [.]\n          --prefix <prefix>        prefix to append to logical paths when constructing urls. use if output dir is not served from the root of your web app []\n          --helpers <js_file>      a .js module of helper functions require()s to expose to transforms []\n          --plugins <js_file>      a .js plugin module []\n\n        If --only is not specified, *all* files in the --paths will be processed.\n\n        Examples:\n\n          Compile all assets in the current directory to /home/me/compiledAssets\n\n            $ asset-smasher /home/me/compiledAssets\n\n          Something similar to what the Rails asset pipeline does by default\n\n            $ asset-smasher --compress --hash --gzip --prefix /assets \\\n                --paths ./js,./css,./images \\\n                --only **/*.{jpg,gif,png},application.js.mf,application.css.mf ./public/assets\n\n          Compile assets, providing some custom helpers to the transformation\n\n            $ asset-smasher --helpers helpers.js output\n\n### <a name=\"cli-helpers\"></a> Helpers\n\nThere is a built-in `asset_path` helper that can be used to get the \"real\" (i.e. with hashed file name) path of an asset.  E.g. `asset_path('css/myFile.css')` might return `'/assets/css/myFile-c89cba7b7df028e65cb01d86f4d27077.css`.\n\nSome transformers (e.g. the `.ejs` one) take in a set of local variables that they can use during transformation. You can pass in the path to a JavaScript module whose exports will be included in this set of variables.\n\nYou can use this, for example, to set configuration parameters in your JS files:\n\n**helper.js**\n\n    exports.serviceUrl = 'http://my.service/';\n\n**config.js.ejs**\n\n    //...\n    var serviceUrl = '<%= serviceUrl %>';\n    var cssLocation = '<%= asset_path('css/myFile.css') %>';\n    //...\n\n**Execution**\n\n    $ asset-smasher --helpers helper.js --only config.js.ejs,css/myFile.css .\n    $ cat config.js\n    var serviceUrl = 'http://my.service/';\n    var cssLocation = '/assets/css/myFile-c89cba7b7df028e65cb01d86f4d27077.css';\n\n\n### <a name=\"cli-plugins\"></a> Plugins\n\nIf there's a type of file you want to pre-process that is not natively supported by Asset Smasher, you can add it using a plugin file.\n\nFor an example of what the transformer classes look like, look in the `lib/compilation/transforms` directory\n\nIf a plugin module is passed (via `--plugins`), it will be `require()`d and then invoked, being passed in the asset smasher library (the module defined in `lib/asset-smasher.js`)\n\nTo register your transformer, just add another entry to the `transforms` object.\n\nE.g.\n\n**my_plugin.js**\n\n    module.exports = function(assetSmasher) {\n       // A stupid transformer that adds \"foo\" to the start and end of the contents\n       var FooTransform = function FooTransform(options) {\n         this.options = options || {};\n       };\n       FooTransform.prototype = {\n         extensions:function () {\n           return ['.foo'];\n         },\n         shouldTransform:function (file) {\n           return path.extname(file) === '.foo';\n         },\n         transformedFileName:function (file) {\n           return path.basename(file, '.foo');\n         },\n         transform:function (asset, cb) {\n           // Transform the file name\n           asset.logicalName = this.transformedFileName(asset.logicalName);\n           // Get the contents\n           var contents = asset.contents;\n           if (Buffer.isBuffer(contents)) {\n             contents = contents.toString('utf-8');\n           }\n           // Compile the contents\n           asset.contents = 'foo-' + contents + '-foo';\n           cb();\n         }\n       };\n\n       assetSmasher.transforms.Foo = FooTransform;\n    };\n\nIf you then invoke `asset-smasher` with `--plugins my_plugin.js` it will automatically transform `*.foo` files.\n\n## <a name=\"express-middleware\"></a> Using via Express Middleware\n\nAsset smasher exposes an `express` middleware that can:\n\n- Serve your assets un-merged/mangled in development mode.\n- Serve precompiled assets (with hashed file names) in production mode.\n\nThe middleware takes in the same arguments as the `Smasher` constructor, with a few extras:\n\n- `serve` - boolean (or object - see more below) indiacating whether the middleware should serve the asset files.  Usualy set this to `true` in development, `false` in production (e.g if you're using precompiled assets)\n    - An object can be passed in with the following properties to control the serving behavior. If `true` is passed in, the default values here will be used\n        - `individual` - Whether the individual (`true`) or merged files (`false`) should be served. Default `true`.\n- `assetMapLocation` - path to the `map.json` generated by the command-line `asset-smasher` util.  This allows the helper methods to determine what the hashed file names were\n\nThe middleware exposes two helpers to your views:\n\n- `js_asset(logicalPath)` - Render a `<script>` tag for the specified JS asset. When `serve` is true, this will \"explode\" manifests and write out a separate `<script>` for each required file.  This makes debugging much easier.\n- `css_asset(logicalPath)` - Render a `<link>` tag for the specified CSS asset.  Same thing happens when `serve` is true as with `js_asset`.\n- `raw_asset(logicalPath)` - Return the path to the asset.\n\n### Example\n\n    var assetSmasher = require('asset-smasher');\n\n**Middleware config (Dev)**\n\n    app.use(assetSmasher.middleware({\n      serve: true,\n      paths: [path.join(__dirname, 'assetDir1'), path.join(__dirname, 'assetDir2')],\n      prefix: '/assets',\n      outputTo: path.join(__dirname, 'tmp')\n    }));\n\n**Middleware config (Prod)**\n\n    app.use(assetSmasher.middleware({\n      serve: false,\n      prefix: '/assets',\n      assetMapLocation: path.join(__dirname, 'public/assets/map.json')\n    }));\n\n**Middleware config (Alternate Prod config not using precompilation, but instead compile on first access)**\n\nNote that if you use this configuration, you will **not** be able to use \"hashed\" filenames.\n\n    app.use(express.staticCache());\n    app.use(express.static(path.join(__dirname, 'public')));\n    app.use(assetSmasher.middleware({\n      serve: {\n        individual: false\n      },\n      paths: [path.join(__dirname, 'assetDir1'), path.join(__dirname, 'assetDir2')],\n      compress: true,\n      prefix: '/assets',\n      // This will make the files be served once by asset smasher\n      // and then by the express \"static\" middleware thereafter.\n      // You can then also use something like \"staticCache\" to cache the files if you're not\n      // using a reverse proxy cache on the public dir\n      outputTo: path.join(__dirname, 'public/assets')\n    }));\n\n**View (ejs here, but could be others)**\n\n    <!DOCTYPE html>\n    <html>\n    <head>\n      <title>Test</title>\n      <%- css_asset('application.css') %>\n      <%- js_asset('application.js') %>\n    </head>\n    <body>\n      This is a test\n    </body>\n    </html>\n\n## <a name=\"programmatic-interface\"></a> Using via Programmatic Interface\n\nYou can invoke Asset Smasher programmatically by `require`ing it.  You can also plug in additional transformers this way.\n\nThe `Smasher` object has the following methods:\n\n - `compileAssets(cb)` - Find and compile all the assets.\n - `compileSingleAsset(assetFilePath, cb)` - Compile a single asset (assetFilePath is the actual path to the file, not a logical path)\n - `findAssets(cb)` - Find, but don't compile the assets.  Good for determining dependency graph without compiling.\n - `getAssetByLogicalPath(logicalPath)` - Get information about an asset by its logical path.  Only call this after finding/compiling assets.\n - `getHashedFileMapping()` - When `hash` is true, this returns a mapping of logical path to \"hashed\" logical path.  This object is what the command-line tool outputs to `map.json`. Only call this after finding/compiling assets.\n - `getRequiredLogicalPathsFor(asset)` - Get the logical paths of the assets that should be merged into the specified asset (populated for `.mf` files). Only call this after finding/compiling assets.\n - `getProcessingOrderLogicalPaths()` - Get a list of the order in which assets should be processed in order to satisfy all dependencies. Only call this after finding/compiling assets.\n - `reset()` - Reset the asset metadata.\n\nThe `Asset` object returned by `getAssetByLogicalPath` has the following properties (and one method):\n\n - `logicalPath` - The logical path\n - `hashedPath` - If `hash` is true, the hashed filename path, otherwise the same as `logicalPath`\n - `assetFilePath` - The full path to the actual source asset\n - `compiled` - Whether the asset has been compiled\n - `compiledAssetFilePath` - The full path to the compiled asset file\n - `reset()` - Set the asset back to its before-compile state (clear out contents, set name back to pre-transform name)\n\n**Example**\n\n    var assetSmasher = require('asset-smasher');\n    var Smasher = assetSmasher.Smasher;\n\n    // Plug in a custom transformer\n    assetSmasher.transforms['MyAwesomeFormat'] = require('myAwesomeFormatTransformer');\n\n    var sm = new Smasher({\n      paths:['/path/one', '/path/two'],\n      only:['**/*.{jpg,gif,png}', 'application.js.mf', 'application.css.mf'],\n      prefix:'/assets',\n      compress:true,\n      hash:true,\n      hashVersion:'1.0',\n      gzip:true,\n      outputTo:__dirname + '/public/assets',\n      helpers:{\n       my: 'helper',\n       another: 'helper'\n      }\n    });\n    sm.compileAssets(function(err) {\n      if(err) {\n        console.log('An error occurred', err);\n      } else {\n        console.log('Compilation done!');\n      }\n    });\n\n## <a name=\"transformer-notes\"></a> Transformer Notes\n\n### <a name=\"tn-less-styl\"></a> LESS/Styles\n\n- Any `@include/@import` paths are *relative to the path that the file is in*.\n- Any `@include/@import`ed files will *not* be processed individually by Asset Smasher (i.e. you can't `@include` a LESS file that is preprocessed by ejs)\n\n### <a name=\"tn-ejs\"></a> ejs\n\n- Any registered helpers will be exposed as global variables to the `ejs` transform.\n- The built-in `asset_paths` helper can be used here.\n\n### <a name=\"tn-dust-hbs\"></a> dust and Handlebars\n\n- The name of the template will be the template's \"logical path\" (minus the asset path it is in), minus the `.js.dust` or `.js.hbs` file extension.\n    - E.g. `/my/templates/test.js.dust`'s template name will be `test` (assuming `/my/templates` is the asset path)\n","readmeFilename":"README.md","_id":"asset-smasher@0.2.5","dist":{"shasum":"cc9128b4894fff823330ce514067f7fcf9ac9b61","tarball":"https://registry.npmjs.org/asset-smasher/-/asset-smasher-0.2.5.tgz","integrity":"sha512-cKiI/fL/qMKGV6sRtXyMjJLHu472+pNo2jKYNJdwBBpLs8xWZvkzZgz5m5HsdqmkBMHtHjVbUK4v30xXN8e8HA==","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEYCIQCCaNktZODZRAvo8ybXr4tRmEypoUN1KiNB0Wv6p5/bkwIhALOvBO/rXkycFZdO+27vQlwCvIyo5+X3+uBHlpFSZBOi"}]},"_from":".","_npmVersion":"1.2.11","_npmUser":{"name":"jriecken","email":"jriecken@gmail.com"},"maintainers":[{"name":"jriecken","email":"jriecken@gmail.com"}]},"0.2.6":{"name":"asset-smasher","description":"Asset pre-processor, merger, and compressor.","version":"0.2.6","author":{"name":"Jim Riecken","email":"jriecken@gmail.com"},"keywords":["asset","compress","merge","preprocess"],"license":{"type":"MIT","url":"http://github.com/jriecken/asset-smasher/raw/master/LICENSE"},"repository":{"type":"git","url":"git://github.com/jriecken/asset-smasher.git"},"bugs":{"url":"http://github.com/jriecken/asset-smasher/issues"},"main":"./lib/asset-smasher.js","bin":{"asset-smasher":"./bin/asset-smasher"},"dependencies":{"async":"0.2.6","commander":"1.1.1","glob":"3.1.21","mkdirp":"0.3.5","minimatch":"0.2.11","send":"0.1.0","uglify-js":"2.2.5","underscore":"1.4.4","ycssmin":"1.0.1"},"optionalDependencies":{},"devDependencies":{},"engines":{"node":">= 0.6.0"},"readme":"# Asset Smasher\n\nAsset pre-processor, merger, and compressor for Node.js\n\n- [Structuring Your Assets](#structure-assets)\n    - [Manifest Files](#manifest-files)\n- [Using via Command Line](#command-line)\n    - [Helpers](#cli-helpers)\n    - [Plugins](#cli-plugins)\n- [Using via Express Middleware](#express-middleware)\n- [Using via Programmatic Interface](#programmatic-interface)\n- [Transformer Notes](#transformer-notes)\n    - [LESS/Stylus](#tn-less-styl)\n    - [ejs](#tn-ejs)\n    - [dust and Handlebars](#tn-dust-hbs)\n\n## Overview\n\nAsset Smasher is a command-line tool, express middleware, and programmatic interface for:\n\n- Pre-processing and transforming files down to plain JavaScript and CSS.\n    - `.coffee` - Compile CoffeeScript into JavaScript\n    - `.ejs` - Run a file through EJS (e.g. to populate configuration parameters into a JavaScript file)\n    - `.less` - Compile Less into CSS\n    - `.styl` - Compile Stylus into CSS\n    - `.hbs` - Precompile Handlebars templates into JavaScript files that register them with `Handlebars.templates`.\n    - `.dust` - Precompile Dust templates into JavaScript files that register them for use with `dust.render`.\n    - Processors can be chained together.  E.g `test.js.hbs.ejs` (run Handlebars template through EJS, then compile it)\n    - Additional processors can be plugged in.\n- Merging files together using Manifest files (`.mf`) with dependency management directives similar to Sprockets.\n    - `require` - Require a single file\n    - `require_dir` - Require all the files in a specific directory\n    - `require_tree` - Require all the files in a specific directory (and subdirectories)\n- Compressing, gzipping, and generating hashed file names.\n    - Compress JavaScript files with `uglify-js`\n    - Compress CSS files with `ycssmin`\n    - Generate Gzipped versions of files\n    - Include a MD5 hash of the file's contents in the file name. `myAsset.js` -> `myAsset-c89cba7b7df028e65cb01d86f4d27077.js`\n        - `asset_path` helper that can be used to reference the hashed name.\n\nIt's released under the [MIT](http://en.wikipedia.org/wiki/MIT_License) license.\n\n## <a name=\"structure-assets\"></a> Structuring Your Assets\n\nAsset Smasher has the concept of \"asset paths\".  These are locations in which your asset files will be located, and from which any relative asset paths will be rooted to.\n\nThe simplest structure has one asset path.\n\nE.g.\n\n    Asset Paths\n    -----------\n     - app\n\n    File Structure\n    --------------\n    app/\n      js/\n      css/\n      images/\n\nA more complicated structure might be\n\n    Asset Paths\n    -----------\n     - app\n     - lib\n     - vendor\n\n    File Structure\n    --------------\n    app/\n      js/\n      css/\n      images/\n    lib/\n      js/\n      css/\n      images/\n    vendor/\n      js/\n      css/\n      images/\n\nBoth of these examples will result in a compiled structure of\n\n    js/\n    css/\n    images/\n\n### <a name=\"manifest-files\"></a> Manifest Files\n\nManifest (`.mf`) files are used to merge many assets into a single resulting file. The file should be named with the resulting file type before the `.mf` extension (e.g. `manifest.css.mf` or `manifest.js.mf`. *Manifest files can `require` other manifest files*\n\nA simple manifest file might look like\n\n    # A comment here\n    require \"./one.js\"\n    require_dir \"./subdir1\"\n    #\n    # Another comment\n    require_tree \"./subdir2\"\n\n**Directives:**\n\n<table border=\"1\" cellpadding=\"5\" cellspacing=\"0\" width=\"100%\">\n <thead>\n  <tr><th width=\"15%\">Directive</th><th width=\"85%\">Description</th></tr>\n </thead>\n <tbody>\n  <tr>\n    <td><code>require \"[path]\"</code></td>\n    <td>\n      <strong>Include a single file</strong>\n      <ul>\n       <li>\n         If the path starts with <code>\"/\"</code>, <code>\"../\"</code>, or <code>\"./\"</code>, process and include the specified file.  The file <em>must</em> be\n         inside one of the configured asset paths.\n       </li>\n       <li>\n         If the path does not start with <code>\"/\"</code>, <code>\"../\"</code>, or <code>\"./\"</code>, the file will be searched for in all of the configured\n         asset paths.  E.g. if there are asset paths <code>one</code> and <code>two</code> defined, <code>require \"js/test.js\"</code>\n         will look for <code>one/js/test.js</code> and then <code>two/js/test.js</code> stopping when it finds a matching file.\n       </li>\n       <li>\n         The filename part of the path does not have to include the whole extension.  E.g <code>require \"test\"</code>\n         finds the first file that matches the name in the asset paths (for example <code>test.js.ejs</code>)\n       </li>\n      </ul>\n    </td>\n  </tr>\n  <tr>\n    <td><code>require_dir \"[path]\"</code></td>\n    <td>\n      <strong>Include all the files in a directory</strong>\n      <ul>\n       <li>\n         The path must be absolute, or relative to the current directory.  E.g. you can do <code>require_dir \"../some/other/dir\"</code>\n         but not <code>require_dir \"somedir\"</code>\n       </li>\n       <li>\n         If using absolute paths, or <code>\"..\"</code> in your paths, the resulting directory needs to be inside one of the configured asset paths.\n       </li>\n       <li>\n         Make sure the directory only contains assets of the type you want.  E.g. for <code>myManifest.js.mf</code>, the dir required had better\n         only contain javascript files, or else bad things will happen.\n       </li>\n      </ul>\n    </td>\n  </tr>\n  <tr>\n    <td><code>require_tree \"[path]\"</code></td>\n    <td>\n      <strong>Include the files in a directory recursively</strong>\n      <ul>\n        <li>The rules for <code>require_tree</code> are the same as the rules for <code>require_dir</code></li>\n      </ul>\n    </td>\n  </tr>\n </tbody>\n</table>\n\n## <a name=\"command-line\"></a> Using via Command-Line\n\nUse `npm install -g asset-smasher` to install the `asset-smasher` command-line tool globally.\n\n      asset-smasher --help\n\n        Usage: asset-smasher [options] <output dir>\n\n        Options:\n\n          -h, --help               output usage information\n          -V, --version            output the version number\n          --compress               compress/minify the generated files\n          --hash                   generate versions of the files with md5 hashes in the name\n          --gzip                   generate gzipped versions of the compiled files\n          --hashVersion <version>  invalidate all assets without changing file contents [1.0]\n          --only <pattern,...>     only process the files matching these glob patterns (relative to any of the paths) [**/*]\n          --paths <path,...>       list of paths to look for assets [.]\n          --prefix <prefix>        prefix to append to logical paths when constructing urls. use if output dir is not served from the root of your web app []\n          --helpers <js_file>      a .js module of helper functions require()s to expose to transforms []\n          --plugins <js_file>      a .js plugin module []\n\n        If --only is not specified, *all* files in the --paths will be processed.\n\n        Examples:\n\n          Compile all assets in the current directory to /home/me/compiledAssets\n\n            $ asset-smasher /home/me/compiledAssets\n\n          Something similar to what the Rails asset pipeline does by default\n\n            $ asset-smasher --compress --hash --gzip --prefix /assets \\\n                --paths ./js,./css,./images \\\n                --only **/*.{jpg,gif,png},application.js.mf,application.css.mf ./public/assets\n\n          Compile assets, providing some custom helpers to the transformation\n\n            $ asset-smasher --helpers helpers.js output\n\n### <a name=\"cli-helpers\"></a> Helpers\n\nThere is a built-in `asset_path` helper that can be used to get the \"real\" (i.e. with hashed file name) path of an asset.  E.g. `asset_path('css/myFile.css')` might return `'/assets/css/myFile-c89cba7b7df028e65cb01d86f4d27077.css`.\n\nSome transformers (e.g. the `.ejs` one) take in a set of local variables that they can use during transformation. You can pass in the path to a JavaScript module whose exports will be included in this set of variables.\n\nYou can use this, for example, to set configuration parameters in your JS files:\n\n**helper.js**\n\n    exports.serviceUrl = 'http://my.service/';\n\n**config.js.ejs**\n\n    //...\n    var serviceUrl = '<%= serviceUrl %>';\n    var cssLocation = '<%= asset_path('css/myFile.css') %>';\n    //...\n\n**Execution**\n\n    $ asset-smasher --helpers helper.js --only config.js.ejs,css/myFile.css .\n    $ cat config.js\n    var serviceUrl = 'http://my.service/';\n    var cssLocation = '/assets/css/myFile-c89cba7b7df028e65cb01d86f4d27077.css';\n\n\n### <a name=\"cli-plugins\"></a> Plugins\n\nIf there's a type of file you want to pre-process that is not natively supported by Asset Smasher, you can add it using a plugin file.\n\nFor an example of what the transformer classes look like, look in the `lib/compilation/transforms` directory\n\nIf a plugin module is passed (via `--plugins`), it will be `require()`d and then invoked, being passed in the asset smasher library (the module defined in `lib/asset-smasher.js`)\n\nTo register your transformer, just add another entry to the `transforms` object.\n\nE.g.\n\n**my_plugin.js**\n\n    module.exports = function(assetSmasher) {\n       // A stupid transformer that adds \"foo\" to the start and end of the contents\n       var FooTransform = function FooTransform(options) {\n         this.options = options || {};\n       };\n       FooTransform.prototype = {\n         extensions:function () {\n           return ['.foo'];\n         },\n         shouldTransform:function (file) {\n           return path.extname(file) === '.foo';\n         },\n         transformedFileName:function (file) {\n           return path.basename(file, '.foo');\n         },\n         transform:function (asset, cb) {\n           // Transform the file name\n           asset.logicalName = this.transformedFileName(asset.logicalName);\n           // Get the contents\n           var contents = asset.contents;\n           if (Buffer.isBuffer(contents)) {\n             contents = contents.toString('utf-8');\n           }\n           // Compile the contents\n           asset.contents = 'foo-' + contents + '-foo';\n           cb();\n         }\n       };\n\n       assetSmasher.transforms.Foo = FooTransform;\n    };\n\nIf you then invoke `asset-smasher` with `--plugins my_plugin.js` it will automatically transform `*.foo` files.\n\n## <a name=\"express-middleware\"></a> Using via Express Middleware\n\nAsset smasher exposes an `express` middleware that can:\n\n- Serve your assets un-merged/mangled in development mode.\n- Serve precompiled assets (with hashed file names) in production mode.\n\nThe middleware takes in the same arguments as the `Smasher` constructor, with a few extras:\n\n- `serve` - boolean (or object - see more below) indiacating whether the middleware should serve the asset files.  Usualy set this to `true` in development, `false` in production (e.g if you're using precompiled assets)\n    - An object can be passed in with the following properties to control the serving behavior. If `true` is passed in, the default values here will be used\n        - `individual` - Whether the individual (`true`) or merged files (`false`) should be served. Default `true`.\n- `assetMapLocation` - path to the `map.json` generated by the command-line `asset-smasher` util.  This allows the helper methods to determine what the hashed file names were\n\nThe middleware exposes two helpers to your views:\n\n- `js_asset(logicalPath)` - Render a `<script>` tag for the specified JS asset. When `serve` is true, this will \"explode\" manifests and write out a separate `<script>` for each required file.  This makes debugging much easier.\n- `css_asset(logicalPath)` - Render a `<link>` tag for the specified CSS asset.  Same thing happens when `serve` is true as with `js_asset`.\n- `raw_asset(logicalPath)` - Return the path to the asset.\n\n### Example\n\n    var assetSmasher = require('asset-smasher');\n\n**Middleware config (Dev)**\n\n    app.use(assetSmasher.middleware({\n      serve: true,\n      paths: [path.join(__dirname, 'assetDir1'), path.join(__dirname, 'assetDir2')],\n      prefix: '/assets',\n      outputTo: path.join(__dirname, 'tmp')\n    }));\n\n**Middleware config (Prod)**\n\n    app.use(assetSmasher.middleware({\n      serve: false,\n      prefix: '/assets',\n      assetMapLocation: path.join(__dirname, 'public/assets/map.json')\n    }));\n\n**Middleware config (Alternate Prod config not using precompilation, but instead compile on first access)**\n\nNote that if you use this configuration, you will **not** be able to use \"hashed\" filenames.\n\n    app.use(express.staticCache());\n    app.use(express.static(path.join(__dirname, 'public')));\n    app.use(assetSmasher.middleware({\n      serve: {\n        individual: false\n      },\n      paths: [path.join(__dirname, 'assetDir1'), path.join(__dirname, 'assetDir2')],\n      compress: true,\n      prefix: '/assets',\n      // This will make the files be served once by asset smasher\n      // and then by the express \"static\" middleware thereafter.\n      // You can then also use something like \"staticCache\" to cache the files if you're not\n      // using a reverse proxy cache on the public dir\n      outputTo: path.join(__dirname, 'public/assets')\n    }));\n\n**View (ejs here, but could be others)**\n\n    <!DOCTYPE html>\n    <html>\n    <head>\n      <title>Test</title>\n      <%- css_asset('application.css') %>\n      <%- js_asset('application.js') %>\n    </head>\n    <body>\n      This is a test\n    </body>\n    </html>\n\n## <a name=\"programmatic-interface\"></a> Using via Programmatic Interface\n\nYou can invoke Asset Smasher programmatically by `require`ing it.  You can also plug in additional transformers this way.\n\nThe `Smasher` object has the following methods:\n\n - `compileAssets(cb)` - Find and compile all the assets.\n - `compileSingleAsset(assetFilePath, cb)` - Compile a single asset (assetFilePath is the actual path to the file, not a logical path)\n - `findAssets(cb)` - Find, but don't compile the assets.  Good for determining dependency graph without compiling.\n - `getAssetByLogicalPath(logicalPath)` - Get information about an asset by its logical path.  Only call this after finding/compiling assets.\n - `getHashedFileMapping()` - When `hash` is true, this returns a mapping of logical path to \"hashed\" logical path.  This object is what the command-line tool outputs to `map.json`. Only call this after finding/compiling assets.\n - `getRequiredLogicalPathsFor(asset)` - Get the logical paths of the assets that should be merged into the specified asset (populated for `.mf` files). Only call this after finding/compiling assets.\n - `getProcessingOrderLogicalPaths()` - Get a list of the order in which assets should be processed in order to satisfy all dependencies. Only call this after finding/compiling assets.\n - `reset()` - Reset the asset metadata.\n\nThe `Asset` object returned by `getAssetByLogicalPath` has the following properties (and one method):\n\n - `logicalPath` - The logical path\n - `hashedPath` - If `hash` is true, the hashed filename path, otherwise the same as `logicalPath`\n - `assetFilePath` - The full path to the actual source asset\n - `compiled` - Whether the asset has been compiled\n - `compiledAssetFilePath` - The full path to the compiled asset file\n - `reset()` - Set the asset back to its before-compile state (clear out contents, set name back to pre-transform name)\n\n**Example**\n\n    var assetSmasher = require('asset-smasher');\n    var Smasher = assetSmasher.Smasher;\n\n    // Plug in a custom transformer\n    assetSmasher.transforms['MyAwesomeFormat'] = require('myAwesomeFormatTransformer');\n\n    var sm = new Smasher({\n      paths:['/path/one', '/path/two'],\n      only:['**/*.{jpg,gif,png}', 'application.js.mf', 'application.css.mf'],\n      prefix:'/assets',\n      compress:true,\n      hash:true,\n      hashVersion:'1.0',\n      gzip:true,\n      outputTo:__dirname + '/public/assets',\n      helpers:{\n       my: 'helper',\n       another: 'helper'\n      }\n    });\n    sm.compileAssets(function(err) {\n      if(err) {\n        console.log('An error occurred', err);\n      } else {\n        console.log('Compilation done!');\n      }\n    });\n\n## <a name=\"transformer-notes\"></a> Transformer Notes\n\n### <a name=\"tn-less-styl\"></a> LESS/Stylus\n\n- Any `@include/@import` paths are *relative to the path that the file is in*.\n- Any `@include/@import`ed files will *not* be processed individually by Asset Smasher (i.e. you can't `@include` a LESS file that is preprocessed by ejs)\n\n### <a name=\"tn-ejs\"></a> ejs\n\n- Any registered helpers will be exposed as global variables to the `ejs` transform.\n- The built-in `asset_paths` helper can be used here.\n\n### <a name=\"tn-dust-hbs\"></a> dust and Handlebars\n\n- The name of the template will be the template's \"logical path\" (minus the asset path it is in), minus the `.js.dust` or `.js.hbs` file extension.\n    - E.g. `/my/templates/test.js.dust`'s template name will be `test` (assuming `/my/templates` is the asset path)\n","readmeFilename":"README.md","_id":"asset-smasher@0.2.6","dist":{"shasum":"8a758bd5010e6d61d7e7b2bcf3b26f1ac2254d39","tarball":"https://registry.npmjs.org/asset-smasher/-/asset-smasher-0.2.6.tgz","integrity":"sha512-2Dz0mVWjMpk2JsubiCJ6+8wEtWeEOsCBHXLGfXtXKq4F7OmqMi/f/fPA0eYnqFGlDFOaXCIcw8Czo581Vq73rQ==","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEQCIBSV1IfxyiLE+JvH2niDqMEcq5rG0V+b9jMcT2yijrrJAiB4KO+cD0ZhWZL1RNdvDjJpOQcl4FIcbs/PHC//g+SUjw=="}]},"_from":".","_npmVersion":"1.2.11","_npmUser":{"name":"jriecken","email":"jriecken@gmail.com"},"maintainers":[{"name":"jriecken","email":"jriecken@gmail.com"}]},"0.2.7":{"name":"asset-smasher","description":"Asset pre-processor, merger, and compressor.","version":"0.2.7","author":{"name":"Jim Riecken","email":"jriecken@gmail.com"},"keywords":["asset","compress","merge","preprocess"],"license":{"type":"MIT","url":"http://github.com/jriecken/asset-smasher/raw/master/LICENSE"},"repository":{"type":"git","url":"git://github.com/jriecken/asset-smasher.git"},"bugs":{"url":"http://github.com/jriecken/asset-smasher/issues"},"main":"./lib/asset-smasher.js","bin":{"asset-smasher":"./bin/asset-smasher"},"dependencies":{"async":"0.2.6","commander":"1.1.1","glob":"3.1.21","mkdirp":"0.3.5","minimatch":"0.2.11","send":"0.1.0","uglify-js":"2.2.5","underscore":"1.4.4","ycssmin":"1.0.1"},"optionalDependencies":{},"devDependencies":{},"engines":{"node":">= 0.6.0"},"readme":"# Asset Smasher\n\nAsset pre-processor, merger, and compressor for Node.js\n\n- [Structuring Your Assets](#structure-assets)\n    - [Manifest Files](#manifest-files)\n- [Using via Command Line](#command-line)\n    - [Helpers](#cli-helpers)\n    - [Plugins](#cli-plugins)\n- [Using via Express Middleware](#express-middleware)\n- [Using via Programmatic Interface](#programmatic-interface)\n- [Transformer Notes](#transformer-notes)\n    - [LESS/Stylus](#tn-less-styl)\n    - [ejs](#tn-ejs)\n    - [dust and Handlebars](#tn-dust-hbs)\n\n## Overview\n\nAsset Smasher is a command-line tool, express middleware, and programmatic interface for:\n\n- Pre-processing and transforming files down to plain JavaScript and CSS.\n    - `.coffee` - Compile CoffeeScript into JavaScript\n    - `.ejs` - Run a file through EJS (e.g. to populate configuration parameters into a JavaScript file)\n    - `.less` - Compile Less into CSS\n    - `.styl` - Compile Stylus into CSS\n    - `.hbs` - Precompile Handlebars templates into JavaScript files that register them with `Handlebars.templates`.\n    - `.dust` - Precompile Dust templates into JavaScript files that register them for use with `dust.render`.\n    - Processors can be chained together.  E.g `test.js.hbs.ejs` (run Handlebars template through EJS, then compile it)\n    - Additional processors can be plugged in.\n- Merging files together using Manifest files (`.mf`) with dependency management directives similar to Sprockets.\n    - `require` - Require a single file\n    - `require_dir` - Require all the files in a specific directory\n    - `require_tree` - Require all the files in a specific directory (and subdirectories)\n- Compressing, gzipping, and generating hashed file names.\n    - Compress JavaScript files with `uglify-js`\n    - Compress CSS files with `ycssmin`\n    - Generate Gzipped versions of files\n    - Include a MD5 hash of the file's contents in the file name. `myAsset.js` -> `myAsset-c89cba7b7df028e65cb01d86f4d27077.js`\n        - `asset_path` helper that can be used to reference the hashed name.\n\nIt's released under the [MIT](http://en.wikipedia.org/wiki/MIT_License) license.\n\n## <a name=\"structure-assets\"></a> Structuring Your Assets\n\nAsset Smasher has the concept of \"asset paths\".  These are locations in which your asset files will be located, and from which any relative asset paths will be rooted to.\n\nThe simplest structure has one asset path.\n\nE.g.\n\n    Asset Paths\n    -----------\n     - app\n\n    File Structure\n    --------------\n    app/\n      js/\n      css/\n      images/\n\nA more complicated structure might be\n\n    Asset Paths\n    -----------\n     - app\n     - lib\n     - vendor\n\n    File Structure\n    --------------\n    app/\n      js/\n      css/\n      images/\n    lib/\n      js/\n      css/\n      images/\n    vendor/\n      js/\n      css/\n      images/\n\nBoth of these examples will result in a compiled structure of\n\n    js/\n    css/\n    images/\n\n### <a name=\"manifest-files\"></a> Manifest Files\n\nManifest (`.mf`) files are used to merge many assets into a single resulting file. The file should be named with the resulting file type before the `.mf` extension (e.g. `manifest.css.mf` or `manifest.js.mf`. *Manifest files can `require` other manifest files*\n\nA simple manifest file might look like\n\n    # A comment here\n    require \"./one.js\"\n    require_dir \"./subdir1\"\n    #\n    # Another comment\n    require_tree \"./subdir2\"\n\n**Directives:**\n\n<table border=\"1\" cellpadding=\"5\" cellspacing=\"0\" width=\"100%\">\n <thead>\n  <tr><th width=\"15%\">Directive</th><th width=\"85%\">Description</th></tr>\n </thead>\n <tbody>\n  <tr>\n    <td><code>require \"[path]\"</code></td>\n    <td>\n      <strong>Include a single file</strong>\n      <ul>\n       <li>\n         If the path starts with <code>\"/\"</code>, <code>\"../\"</code>, or <code>\"./\"</code>, process and include the specified file.  The file <em>must</em> be\n         inside one of the configured asset paths.\n       </li>\n       <li>\n         If the path does not start with <code>\"/\"</code>, <code>\"../\"</code>, or <code>\"./\"</code>, the file will be searched for in all of the configured\n         asset paths.  E.g. if there are asset paths <code>one</code> and <code>two</code> defined, <code>require \"js/test.js\"</code>\n         will look for <code>one/js/test.js</code> and then <code>two/js/test.js</code> stopping when it finds a matching file.\n       </li>\n       <li>\n         The filename part of the path does not have to include the whole extension.  E.g <code>require \"test\"</code>\n         finds the first file that matches the name in the asset paths (for example <code>test.js.ejs</code>)\n       </li>\n      </ul>\n    </td>\n  </tr>\n  <tr>\n    <td><code>require_dir \"[path]\"</code></td>\n    <td>\n      <strong>Include all the files in a directory</strong>\n      <ul>\n       <li>\n         The path must be absolute, or relative to the current directory.  E.g. you can do <code>require_dir \"../some/other/dir\"</code>\n         but not <code>require_dir \"somedir\"</code>\n       </li>\n       <li>\n         If using absolute paths, or <code>\"..\"</code> in your paths, the resulting directory needs to be inside one of the configured asset paths.\n       </li>\n       <li>\n         Make sure the directory only contains assets of the type you want.  E.g. for <code>myManifest.js.mf</code>, the dir required had better\n         only contain javascript files, or else bad things will happen.\n       </li>\n      </ul>\n    </td>\n  </tr>\n  <tr>\n    <td><code>require_tree \"[path]\"</code></td>\n    <td>\n      <strong>Include the files in a directory recursively</strong>\n      <ul>\n        <li>The rules for <code>require_tree</code> are the same as the rules for <code>require_dir</code></li>\n      </ul>\n    </td>\n  </tr>\n </tbody>\n</table>\n\n## <a name=\"command-line\"></a> Using via Command-Line\n\nUse `npm install -g asset-smasher` to install the `asset-smasher` command-line tool globally.\n\n      asset-smasher --help\n\n        Usage: asset-smasher [options] <output dir>\n\n        Options:\n\n          -h, --help               output usage information\n          -V, --version            output the version number\n          --compress               compress/minify the generated files\n          --hash                   generate versions of the files with md5 hashes in the name\n          --gzip                   generate gzipped versions of the compiled files\n          --hashVersion <version>  invalidate all assets without changing file contents [1.0]\n          --only <pattern,...>     only process the files matching these glob patterns (relative to any of the paths) [**/*]\n          --paths <path,...>       list of paths to look for assets [.]\n          --prefix <prefix>        prefix to append to logical paths when constructing urls. use if output dir is not served from the root of your web app []\n          --helpers <js_file>      a .js module of helper functions require()s to expose to transforms []\n          --plugins <js_file>      a .js plugin module []\n\n        If --only is not specified, *all* files in the --paths will be processed.\n\n        Examples:\n\n          Compile all assets in the current directory to /home/me/compiledAssets\n\n            $ asset-smasher /home/me/compiledAssets\n\n          Something similar to what the Rails asset pipeline does by default\n\n            $ asset-smasher --compress --hash --gzip --prefix /assets \\\n                --paths ./js,./css,./images \\\n                --only **/*.{jpg,gif,png},application.js.mf,application.css.mf ./public/assets\n\n          Compile assets, providing some custom helpers to the transformation\n\n            $ asset-smasher --helpers helpers.js output\n\n### <a name=\"cli-helpers\"></a> Helpers\n\nThere is a built-in `asset_path` helper that can be used to get the \"real\" (i.e. with hashed file name) path of an asset.  E.g. `asset_path('css/myFile.css')` might return `'/assets/css/myFile-c89cba7b7df028e65cb01d86f4d27077.css`.\n\nSome transformers (e.g. the `.ejs` one) take in a set of local variables that they can use during transformation. You can pass in the path to a JavaScript module whose exports will be included in this set of variables.\n\nYou can use this, for example, to set configuration parameters in your JS files:\n\n**helper.js**\n\n    exports.serviceUrl = 'http://my.service/';\n\n**config.js.ejs**\n\n    //...\n    var serviceUrl = '<%= serviceUrl %>';\n    var cssLocation = '<%= asset_path('css/myFile.css') %>';\n    //...\n\n**Execution**\n\n    $ asset-smasher --helpers helper.js --only config.js.ejs,css/myFile.css .\n    $ cat config.js\n    var serviceUrl = 'http://my.service/';\n    var cssLocation = '/assets/css/myFile-c89cba7b7df028e65cb01d86f4d27077.css';\n\n\n### <a name=\"cli-plugins\"></a> Plugins\n\nIf there's a type of file you want to pre-process that is not natively supported by Asset Smasher, you can add it using a plugin file.\n\nFor an example of what the transformer classes look like, look in the `lib/compilation/transforms` directory\n\nIf a plugin module is passed (via `--plugins`), it will be `require()`d and then invoked, being passed in the asset smasher library (the module defined in `lib/asset-smasher.js`)\n\nTo register your transformer, just add another entry to the `transforms` object.\n\nE.g.\n\n**my_plugin.js**\n\n    module.exports = function(assetSmasher) {\n       // A stupid transformer that adds \"foo\" to the start and end of the contents\n       var FooTransform = function FooTransform(options) {\n         this.options = options || {};\n       };\n       FooTransform.prototype = {\n         extensions:function () {\n           return ['.foo'];\n         },\n         shouldTransform:function (file) {\n           return path.extname(file) === '.foo';\n         },\n         transformedFileName:function (file) {\n           return path.basename(file, '.foo');\n         },\n         transform:function (asset, cb) {\n           // Transform the file name\n           asset.logicalName = this.transformedFileName(asset.logicalName);\n           // Get the contents\n           var contents = asset.contents;\n           if (Buffer.isBuffer(contents)) {\n             contents = contents.toString('utf-8');\n           }\n           // Compile the contents\n           asset.contents = 'foo-' + contents + '-foo';\n           cb();\n         }\n       };\n\n       assetSmasher.transforms.Foo = FooTransform;\n    };\n\nIf you then invoke `asset-smasher` with `--plugins my_plugin.js` it will automatically transform `*.foo` files.\n\n## <a name=\"express-middleware\"></a> Using via Express Middleware\n\nAsset smasher exposes an `express` middleware that can:\n\n- Serve your assets un-merged/mangled in development mode.\n- Serve precompiled assets (with hashed file names) in production mode.\n\nThe middleware takes in the same arguments as the `Smasher` constructor, with a few extras:\n\n- `serve` - boolean (or object - see more below) indiacating whether the middleware should serve the asset files.  Usualy set this to `true` in development, `false` in production (e.g if you're using precompiled assets)\n    - An object can be passed in with the following properties to control the serving behavior. If `true` is passed in, the default values here will be used\n        - `individual` - Whether the individual (`true`) or merged files (`false`) should be served. Default `true`.\n- `assetMapLocation` - path to the `map.json` generated by the command-line `asset-smasher` util.  This allows the helper methods to determine what the hashed file names were\n\nThe middleware exposes two helpers to your views:\n\n- `js_asset(logicalPath)` - Render a `<script>` tag for the specified JS asset. When `serve` is true, this will \"explode\" manifests and write out a separate `<script>` for each required file.  This makes debugging much easier.\n- `css_asset(logicalPath)` - Render a `<link>` tag for the specified CSS asset.  Same thing happens when `serve` is true as with `js_asset`.\n- `raw_asset(logicalPath)` - Return the path to the asset.\n\n### Example\n\n    var assetSmasher = require('asset-smasher');\n\n**Middleware config (Dev)**\n\n    app.use(assetSmasher.middleware({\n      serve: true,\n      paths: [path.join(__dirname, 'assetDir1'), path.join(__dirname, 'assetDir2')],\n      prefix: '/assets',\n      outputTo: path.join(__dirname, 'tmp')\n    }));\n\n**Middleware config (Prod)**\n\n    app.use(assetSmasher.middleware({\n      serve: false,\n      prefix: '/assets',\n      assetMapLocation: path.join(__dirname, 'public/assets/map.json')\n    }));\n\n**Middleware config (Alternate Prod config not using precompilation, but instead compile on first access)**\n\nNote that if you use this configuration, you will **not** be able to use \"hashed\" filenames.\n\n    app.use(express.staticCache());\n    app.use(express.static(path.join(__dirname, 'public')));\n    app.use(assetSmasher.middleware({\n      serve: {\n        individual: false\n      },\n      paths: [path.join(__dirname, 'assetDir1'), path.join(__dirname, 'assetDir2')],\n      compress: true,\n      prefix: '/assets',\n      // This will make the files be served once by asset smasher\n      // and then by the express \"static\" middleware thereafter.\n      // You can then also use something like \"staticCache\" to cache the files if you're not\n      // using a reverse proxy cache on the public dir\n      outputTo: path.join(__dirname, 'public/assets')\n    }));\n\n**View (ejs here, but could be others)**\n\n    <!DOCTYPE html>\n    <html>\n    <head>\n      <title>Test</title>\n      <%- css_asset('application.css') %>\n      <%- js_asset('application.js') %>\n    </head>\n    <body>\n      This is a test\n    </body>\n    </html>\n\n## <a name=\"programmatic-interface\"></a> Using via Programmatic Interface\n\nYou can invoke Asset Smasher programmatically by `require`ing it.  You can also plug in additional transformers this way.\n\nThe `Smasher` object has the following methods:\n\n - `compileAssets(cb)` - Find and compile all the assets.\n - `compileSingleAsset(assetFilePath, cb)` - Compile a single asset (assetFilePath is the actual path to the file, not a logical path)\n - `findAssets(cb)` - Find, but don't compile the assets.  Good for determining dependency graph without compiling.\n - `getAssetByLogicalPath(logicalPath)` - Get information about an asset by its logical path.  Only call this after finding/compiling assets.\n - `getHashedFileMapping()` - When `hash` is true, this returns a mapping of logical path to \"hashed\" logical path.  This object is what the command-line tool outputs to `map.json`. Only call this after finding/compiling assets.\n - `getRequiredLogicalPathsFor(asset)` - Get the logical paths of the assets that should be merged into the specified asset (populated for `.mf` files). Only call this after finding/compiling assets.\n - `getProcessingOrderLogicalPaths()` - Get a list of the order in which assets should be processed in order to satisfy all dependencies. Only call this after finding/compiling assets.\n - `reset()` - Reset the asset metadata.\n\nThe `Asset` object returned by `getAssetByLogicalPath` has the following properties (and one method):\n\n - `logicalPath` - The logical path\n - `hashedPath` - If `hash` is true, the hashed filename path, otherwise the same as `logicalPath`\n - `assetFilePath` - The full path to the actual source asset\n - `compiled` - Whether the asset has been compiled\n - `compiledAssetFilePath` - The full path to the compiled asset file\n - `reset()` - Set the asset back to its before-compile state (clear out contents, set name back to pre-transform name)\n\n**Example**\n\n    var assetSmasher = require('asset-smasher');\n    var Smasher = assetSmasher.Smasher;\n\n    // Plug in a custom transformer\n    assetSmasher.transforms['MyAwesomeFormat'] = require('myAwesomeFormatTransformer');\n\n    var sm = new Smasher({\n      paths:['/path/one', '/path/two'],\n      only:['**/*.{jpg,gif,png}', 'application.js.mf', 'application.css.mf'],\n      prefix:'/assets',\n      compress:true,\n      hash:true,\n      hashVersion:'1.0',\n      gzip:true,\n      outputTo:__dirname + '/public/assets',\n      helpers:{\n       my: 'helper',\n       another: 'helper'\n      }\n    });\n    sm.compileAssets(function(err) {\n      if(err) {\n        console.log('An error occurred', err);\n      } else {\n        console.log('Compilation done!');\n      }\n    });\n\n## <a name=\"transformer-notes\"></a> Transformer Notes\n\n### <a name=\"tn-less-styl\"></a> LESS/Stylus\n\n- Any `@include/@import` paths are *relative to the path that the file is in*.\n- Any `@include/@import`ed files will *not* be processed individually by Asset Smasher (i.e. you can't `@include` a LESS file that is preprocessed by ejs)\n\n### <a name=\"tn-ejs\"></a> ejs\n\n- Any registered helpers will be exposed as global variables to the `ejs` transform.\n- The built-in `asset_paths` helper can be used here.\n\n### <a name=\"tn-dust-hbs\"></a> dust and Handlebars\n\n- The name of the template will be the template's \"logical path\" (minus the asset path it is in), minus the `.js.dust` or `.js.hbs` file extension.\n    - E.g. `/my/templates/test.js.dust`'s template name will be `test` (assuming `/my/templates` is the asset path)\n","readmeFilename":"README.md","_id":"asset-smasher@0.2.7","dist":{"shasum":"440b6239374c935575e10f0c4352d3941f605dc5","tarball":"https://registry.npmjs.org/asset-smasher/-/asset-smasher-0.2.7.tgz","integrity":"sha512-w7siG1zQeaZ1pku4QtwIrC+ZmpLavMpnAcSf2G7yl6mWza3ghSo9GXbAu41fjxiVV9erf7yGesN7UF7eo2Trnw==","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEQCIC4+T8Rqt2LZ6PAcs6KlkBcyIY2GW3f9EwnFF7etIKQxAiBbXNta9acpgbr/kiBgQ0kKrigsMuYBRpIPjzdrpLDEoQ=="}]},"_from":".","_npmVersion":"1.2.11","_npmUser":{"name":"jriecken","email":"jriecken@gmail.com"},"maintainers":[{"name":"jriecken","email":"jriecken@gmail.com"}]},"0.2.8":{"name":"asset-smasher","description":"Asset pre-processor, merger, and compressor.","version":"0.2.8","author":{"name":"Jim Riecken","email":"jriecken@gmail.com"},"keywords":["asset","compress","merge","preprocess"],"license":{"type":"MIT","url":"http://github.com/jriecken/asset-smasher/raw/master/LICENSE"},"repository":{"type":"git","url":"git://github.com/jriecken/asset-smasher.git"},"bugs":{"url":"http://github.com/jriecken/asset-smasher/issues"},"main":"./lib/asset-smasher.js","bin":{"asset-smasher":"./bin/asset-smasher"},"dependencies":{"async":"0.2.6","commander":"1.1.1","glob":"3.1.21","mkdirp":"0.3.5","minimatch":"0.2.11","send":"0.1.0","uglify-js":"2.2.5","underscore":"1.4.4","ycssmin":"1.0.1"},"optionalDependencies":{},"devDependencies":{},"engines":{"node":">= 0.6.0"},"readme":"# Asset Smasher\n\nAsset pre-processor, merger, and compressor for Node.js\n\n- [Structuring Your Assets](#structure-assets)\n    - [Manifest Files](#manifest-files)\n    - [Manifest Directories](#manifest-directories)\n- [Using via Command Line](#command-line)\n    - [Helpers](#cli-helpers)\n    - [Plugins](#cli-plugins)\n- [Using via Express Middleware](#express-middleware)\n- [Using via Programmatic Interface](#programmatic-interface)\n- [Transformer Notes](#transformer-notes)\n    - [LESS/Stylus](#tn-less-styl)\n    - [ejs](#tn-ejs)\n    - [dust and Handlebars](#tn-dust-hbs)\n\n## Overview\n\nAsset Smasher is a command-line tool, express middleware, and programmatic interface for:\n\n- Pre-processing and transforming files down to plain JavaScript and CSS.\n    - `.coffee` - Compile CoffeeScript into JavaScript\n    - `.ejs` - Run a file through EJS (e.g. to populate configuration parameters into a JavaScript file)\n    - `.less` - Compile Less into CSS\n    - `.styl` - Compile Stylus into CSS\n    - `.hbs` - Precompile Handlebars templates into JavaScript files that register them with `Handlebars.templates`.\n    - `.dust` - Precompile Dust templates into JavaScript files that register them for use with `dust.render`.\n    - Processors can be chained together.  E.g `test.js.hbs.ejs` (run Handlebars template through EJS, then compile it)\n    - Additional processors can be plugged in.\n- Merging files together using Manifest files (`.mf`) with dependency management directives similar to Sprockets.\n    - `require` - Require a single file\n    - `require_dir` - Require all the files in a specific directory\n    - `require_tree` - Require all the files in a specific directory (and subdirectories)\n- Compressing, gzipping, and generating hashed file names.\n    - Compress JavaScript files with `uglify-js`\n    - Compress CSS files with `ycssmin`\n    - Generate Gzipped versions of files\n    - Include a MD5 hash of the file's contents in the file name. `myAsset.js` -> `myAsset-c89cba7b7df028e65cb01d86f4d27077.js`\n        - `asset_path` helper that can be used to reference the hashed name.\n\nIt's released under the [MIT](http://en.wikipedia.org/wiki/MIT_License) license.\n\n## <a name=\"structure-assets\"></a> Structuring Your Assets\n\nAsset Smasher has the concept of \"asset paths\".  These are locations in which your asset files will be located, and from which any relative asset paths will be rooted to.\n\nThe simplest structure has one asset path.\n\nE.g.\n\n    Asset Paths\n    -----------\n     - app\n\n    File Structure\n    --------------\n    app/\n      js/\n      css/\n      images/\n\nA more complicated structure might be\n\n    Asset Paths\n    -----------\n     - app\n     - lib\n     - vendor\n\n    File Structure\n    --------------\n    app/\n      js/\n      css/\n      images/\n    lib/\n      js/\n      css/\n      images/\n    vendor/\n      js/\n      css/\n      images/\n\nBoth of these examples will result in a compiled structure of\n\n    js/\n    css/\n    images/\n\n### <a name=\"manifest-files\"></a> Manifest Files\n\nManifest (`.mf`) files are used to merge many assets into a single resulting file. The file should be named with the resulting file type before the `.mf` extension (e.g. `manifest.css.mf` or `manifest.js.mf`. *Manifest files can `require` other manifest files*\n\nA simple manifest file might look like\n\n    # A comment here\n    require \"./one.js\"\n    require_dir \"./subdir1\"\n    #\n    # Another comment\n    require_tree \"./subdir2\"\n\n**Directives:**\n\n<table border=\"1\" cellpadding=\"5\" cellspacing=\"0\" width=\"100%\">\n <thead>\n  <tr><th width=\"15%\">Directive</th><th width=\"85%\">Description</th></tr>\n </thead>\n <tbody>\n  <tr>\n    <td><code>require \"[path]\"</code></td>\n    <td>\n      <strong>Include a single file</strong>\n      <ul>\n       <li>\n         If the path starts with <code>\"/\"</code>, <code>\"../\"</code>, or <code>\"./\"</code>, process and include the specified file.  The file <em>must</em> be\n         inside one of the configured asset paths.\n       </li>\n       <li>\n         If the path does not start with <code>\"/\"</code>, <code>\"../\"</code>, or <code>\"./\"</code>, the file will be searched for in all of the configured\n         asset paths.  E.g. if there are asset paths <code>one</code> and <code>two</code> defined, <code>require \"js/test.js\"</code>\n         will look for <code>one/js/test.js</code> and then <code>two/js/test.js</code> stopping when it finds a matching file.\n       </li>\n       <li>\n         The filename part of the path does not have to include the whole extension.  E.g <code>require \"test\"</code>\n         finds the first file that matches the name in the asset paths (for example <code>test.js.ejs</code>)\n       </li>\n      </ul>\n    </td>\n  </tr>\n  <tr>\n    <td><code>require_dir \"[path]\"</code></td>\n    <td>\n      <strong>Include all the files in a directory</strong>\n      <ul>\n       <li>\n         The path must be absolute, or relative to the current directory.  E.g. you can do <code>require_dir \"../some/other/dir\"</code>\n         but not <code>require_dir \"somedir\"</code>\n       </li>\n       <li>\n         If using absolute paths, or <code>\"..\"</code> in your paths, the resulting directory needs to be inside one of the configured asset paths.\n       </li>\n       <li>\n         Make sure the directory only contains assets of the type you want.  E.g. for <code>myManifest.js.mf</code>, the dir required had better\n         only contain javascript files, or else bad things will happen.\n       </li>\n      </ul>\n    </td>\n  </tr>\n  <tr>\n    <td><code>require_tree \"[path]\"</code></td>\n    <td>\n      <strong>Include the files in a directory recursively</strong>\n      <ul>\n        <li>The rules for <code>require_tree</code> are the same as the rules for <code>require_dir</code></li>\n      </ul>\n    </td>\n  </tr>\n </tbody>\n</table>\n\n### <a name=\"manifest-directories\"></a> Manifest Directories\n\nIf you create a directory, for example named `foo.js.mf` and put a bunch of javascript files in it (or any subdirectories under it), `asset-smasher` will (recursively) take all the files inside and merge them into `foo.js`.\n\nEssentially, this is a time-saver so that you don't have to create a manifest file that only contains a single `require_tree` directive.\n\n## <a name=\"command-line\"></a> Using via Command-Line\n\nUse `npm install -g asset-smasher` to install the `asset-smasher` command-line tool globally.\n\n      asset-smasher --help\n\n        Usage: asset-smasher [options] <output dir>\n\n        Options:\n\n          -h, --help               output usage information\n          -V, --version            output the version number\n          --compress               compress/minify the generated files\n          --hash                   generate versions of the files with md5 hashes in the name\n          --gzip                   generate gzipped versions of the compiled files\n          --hashVersion <version>  invalidate all assets without changing file contents [1.0]\n          --only <pattern,...>     only process the files matching these glob patterns (relative to any of the paths) [**/*]\n          --paths <path,...>       list of paths to look for assets [.]\n          --prefix <prefix>        prefix to append to logical paths when constructing urls. use if output dir is not served from the root of your web app []\n          --helpers <js_file>      a .js module of helper functions require()s to expose to transforms []\n          --plugins <js_file>      a .js plugin module []\n\n        If --only is not specified, *all* files in the --paths will be processed.\n\n        Examples:\n\n          Compile all assets in the current directory to /home/me/compiledAssets\n\n            $ asset-smasher /home/me/compiledAssets\n\n          Something similar to what the Rails asset pipeline does by default\n\n            $ asset-smasher --compress --hash --gzip --prefix /assets \\\n                --paths ./js,./css,./images \\\n                --only **/*.{jpg,gif,png},application.js.mf,application.css.mf ./public/assets\n\n          Compile assets, providing some custom helpers to the transformation\n\n            $ asset-smasher --helpers helpers.js output\n\n### <a name=\"cli-helpers\"></a> Helpers\n\nThere is a built-in `asset_path` helper that can be used to get the \"real\" (i.e. with hashed file name) path of an asset.  E.g. `asset_path('css/myFile.css')` might return `'/assets/css/myFile-c89cba7b7df028e65cb01d86f4d27077.css`.\n\nSome transformers (e.g. the `.ejs` one) take in a set of local variables that they can use during transformation. You can pass in the path to a JavaScript module whose exports will be included in this set of variables.\n\nYou can use this, for example, to set configuration parameters in your JS files:\n\n**helper.js**\n\n    exports.serviceUrl = 'http://my.service/';\n\n**config.js.ejs**\n\n    //...\n    var serviceUrl = '<%= serviceUrl %>';\n    var cssLocation = '<%= asset_path('css/myFile.css') %>';\n    //...\n\n**Execution**\n\n    $ asset-smasher --helpers helper.js --only config.js.ejs,css/myFile.css .\n    $ cat config.js\n    var serviceUrl = 'http://my.service/';\n    var cssLocation = '/assets/css/myFile-c89cba7b7df028e65cb01d86f4d27077.css';\n\n\n### <a name=\"cli-plugins\"></a> Plugins\n\nIf there's a type of file you want to pre-process that is not natively supported by Asset Smasher, you can add it using a plugin file.\n\nFor an example of what the transformer classes look like, look in the `lib/compilation/transforms` directory\n\nIf a plugin module is passed (via `--plugins`), it will be `require()`d and then invoked, being passed in the asset smasher library (the module defined in `lib/asset-smasher.js`)\n\nTo register your transformer, just add another entry to the `transforms` object.\n\nE.g.\n\n**my_plugin.js**\n\n    module.exports = function(assetSmasher) {\n       // A stupid transformer that adds \"foo\" to the start and end of the contents\n       var FooTransform = function FooTransform(options) {\n         this.options = options || {};\n       };\n       FooTransform.prototype = {\n         extensions:function () {\n           return ['.foo'];\n         },\n         shouldTransform:function (file) {\n           return path.extname(file) === '.foo';\n         },\n         transformedFileName:function (file) {\n           return path.basename(file, '.foo');\n         },\n         transform:function (asset, cb) {\n           // Transform the file name\n           asset.logicalName = this.transformedFileName(asset.logicalName);\n           // Get the contents\n           var contents = asset.contents;\n           if (Buffer.isBuffer(contents)) {\n             contents = contents.toString('utf-8');\n           }\n           // Compile the contents\n           asset.contents = 'foo-' + contents + '-foo';\n           cb();\n         }\n       };\n\n       assetSmasher.transforms.Foo = FooTransform;\n    };\n\nIf you then invoke `asset-smasher` with `--plugins my_plugin.js` it will automatically transform `*.foo` files.\n\n## <a name=\"express-middleware\"></a> Using via Express Middleware\n\nAsset smasher exposes an `express` middleware that can:\n\n- Serve your assets un-merged/mangled in development mode.\n- Serve precompiled assets (with hashed file names) in production mode.\n\nThe middleware takes in the same arguments as the `Smasher` constructor, with a few extras:\n\n- `serve` - boolean (or object - see more below) indiacating whether the middleware should serve the asset files.  Usualy set this to `true` in development, `false` in production (e.g if you're using precompiled assets)\n    - An object can be passed in with the following properties to control the serving behavior. If `true` is passed in, the default values here will be used\n        - `individual` - Whether the individual (`true`) or merged files (`false`) should be served. Default `true`.\n- `assetMapLocation` - path to the `map.json` generated by the command-line `asset-smasher` util.  This allows the helper methods to determine what the hashed file names were\n\nThe middleware exposes two helpers to your views:\n\n- `js_asset(logicalPath)` - Render a `<script>` tag for the specified JS asset. When `serve` is true, this will \"explode\" manifests and write out a separate `<script>` for each required file.  This makes debugging much easier.\n- `css_asset(logicalPath)` - Render a `<link>` tag for the specified CSS asset.  Same thing happens when `serve` is true as with `js_asset`.\n- `raw_asset(logicalPath)` - Return the path to the asset.\n\n### Example\n\n    var assetSmasher = require('asset-smasher');\n\n**Middleware config (Dev)**\n\n    app.use(assetSmasher.middleware({\n      serve: true,\n      paths: [path.join(__dirname, 'assetDir1'), path.join(__dirname, 'assetDir2')],\n      prefix: '/assets',\n      outputTo: path.join(__dirname, 'tmp')\n    }));\n\n**Middleware config (Prod)**\n\n    app.use(assetSmasher.middleware({\n      serve: false,\n      prefix: '/assets',\n      assetMapLocation: path.join(__dirname, 'public/assets/map.json')\n    }));\n\n**Middleware config (Alternate Prod config not using precompilation, but instead compile on first access)**\n\nNote that if you use this configuration, you will **not** be able to use \"hashed\" filenames.\n\n    app.use(express.staticCache());\n    app.use(express.static(path.join(__dirname, 'public')));\n    app.use(assetSmasher.middleware({\n      serve: {\n        individual: false\n      },\n      paths: [path.join(__dirname, 'assetDir1'), path.join(__dirname, 'assetDir2')],\n      compress: true,\n      prefix: '/assets',\n      // This will make the files be served once by asset smasher\n      // and then by the express \"static\" middleware thereafter.\n      // You can then also use something like \"staticCache\" to cache the files if you're not\n      // using a reverse proxy cache on the public dir\n      outputTo: path.join(__dirname, 'public/assets')\n    }));\n\n**View (ejs here, but could be others)**\n\n    <!DOCTYPE html>\n    <html>\n    <head>\n      <title>Test</title>\n      <%- css_asset('application.css') %>\n      <%- js_asset('application.js') %>\n    </head>\n    <body>\n      This is a test\n    </body>\n    </html>\n\n## <a name=\"programmatic-interface\"></a> Using via Programmatic Interface\n\nYou can invoke Asset Smasher programmatically by `require`ing it.  You can also plug in additional transformers this way.\n\nThe `Smasher` object has the following methods:\n\n - `compileAssets(cb)` - Find and compile all the assets.\n - `compileSingleAsset(assetFilePath, cb)` - Compile a single asset (assetFilePath is the actual path to the file, not a logical path)\n - `findAssets(cb)` - Find, but don't compile the assets.  Good for determining dependency graph without compiling.\n - `getAssetByLogicalPath(logicalPath)` - Get information about an asset by its logical path.  Only call this after finding/compiling assets.\n - `getHashedFileMapping()` - When `hash` is true, this returns a mapping of logical path to \"hashed\" logical path.  This object is what the command-line tool outputs to `map.json`. Only call this after finding/compiling assets.\n - `getRequiredLogicalPathsFor(asset)` - Get the logical paths of the assets that should be merged into the specified asset (populated for `.mf` files). Only call this after finding/compiling assets.\n - `getProcessingOrderLogicalPaths()` - Get a list of the order in which assets should be processed in order to satisfy all dependencies. Only call this after finding/compiling assets.\n - `reset()` - Reset the asset metadata.\n\nThe `Asset` object returned by `getAssetByLogicalPath` has the following properties (and one method):\n\n - `logicalPath` - The logical path\n - `hashedPath` - If `hash` is true, the hashed filename path, otherwise the same as `logicalPath`\n - `assetFilePath` - The full path to the actual source asset\n - `compiled` - Whether the asset has been compiled\n - `compiledAssetFilePath` - The full path to the compiled asset file\n - `reset()` - Set the asset back to its before-compile state (clear out contents, set name back to pre-transform name)\n\n**Example**\n\n    var assetSmasher = require('asset-smasher');\n    var Smasher = assetSmasher.Smasher;\n\n    // Plug in a custom transformer\n    assetSmasher.transforms['MyAwesomeFormat'] = require('myAwesomeFormatTransformer');\n\n    var sm = new Smasher({\n      paths:['/path/one', '/path/two'],\n      only:['**/*.{jpg,gif,png}', 'application.js.mf', 'application.css.mf'],\n      prefix:'/assets',\n      compress:true,\n      hash:true,\n      hashVersion:'1.0',\n      gzip:true,\n      outputTo:__dirname + '/public/assets',\n      helpers:{\n       my: 'helper',\n       another: 'helper'\n      }\n    });\n    sm.compileAssets(function(err) {\n      if(err) {\n        console.log('An error occurred', err);\n      } else {\n        console.log('Compilation done!');\n      }\n    });\n\n## <a name=\"transformer-notes\"></a> Transformer Notes\n\n### <a name=\"tn-less-styl\"></a> LESS/Stylus\n\n- Any `@include/@import` paths are *relative to the path that the file is in*.\n- Any `@include/@import`ed files will *not* be processed individually by Asset Smasher (i.e. you can't `@include` a LESS file that is preprocessed by ejs)\n\n### <a name=\"tn-ejs\"></a> ejs\n\n- Any registered helpers will be exposed as global variables to the `ejs` transform.\n- The built-in `asset_paths` helper can be used here.\n\n### <a name=\"tn-dust-hbs\"></a> dust and Handlebars\n\n- The name of the template will be the template's \"logical path\" (minus the asset path it is in), minus the `.js.dust` or `.js.hbs` file extension.\n    - E.g. `/my/templates/test.js.dust`'s template name will be `test` (assuming `/my/templates` is the asset path)\n","readmeFilename":"README.md","_id":"asset-smasher@0.2.8","dist":{"shasum":"79ee1f223f38d4c55625a47b86f45cd115555c9e","tarball":"https://registry.npmjs.org/asset-smasher/-/asset-smasher-0.2.8.tgz","integrity":"sha512-gWKcNz6hoq1Rj04UoZpjVn9b4giyaxui2IuRUNpwShdXlovJMoAA3xu4zjRn0GUOAFXoTtqbGAg9ONnc8CsK+Q==","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEQCIEH2qIEGeDaDPQ3m2l1PV0D2Zau6MZXSewK9x9HfCWNiAiBIiKLsv/sGpjFs9LDhUn1JwzxZzVe6k/N1paSErAYc1w=="}]},"_from":".","_npmVersion":"1.2.18","_npmUser":{"name":"jriecken","email":"jriecken@gmail.com"},"maintainers":[{"name":"jriecken","email":"jriecken@gmail.com"}]},"0.2.9":{"name":"asset-smasher","description":"Asset pre-processor, merger, and compressor.","version":"0.2.9","author":{"name":"Jim Riecken","email":"jriecken@gmail.com"},"keywords":["asset","compress","merge","preprocess"],"license":{"type":"MIT","url":"http://github.com/jriecken/asset-smasher/raw/master/LICENSE"},"repository":{"type":"git","url":"git://github.com/jriecken/asset-smasher.git"},"bugs":{"url":"http://github.com/jriecken/asset-smasher/issues"},"main":"./lib/asset-smasher.js","bin":{"asset-smasher":"./bin/asset-smasher"},"dependencies":{"async":"0.2.6","commander":"1.1.1","glob":"3.1.21","mkdirp":"0.3.5","minimatch":"0.2.11","rimraf":"2.1.4","send":"0.1.0","uglify-js":"2.2.5","underscore":"1.4.4","ycssmin":"1.0.1"},"optionalDependencies":{},"devDependencies":{},"engines":{"node":">= 0.6.0"},"readme":"# Asset Smasher\n\nAsset pre-processor, merger, and compressor for Node.js\n\n- [Structuring Your Assets](#structure-assets)\n    - [Manifest Files](#manifest-files)\n    - [Manifest Directories](#manifest-directories)\n- [Using via Command Line](#command-line)\n    - [Helpers](#cli-helpers)\n    - [Plugins](#cli-plugins)\n- [Using via Express Middleware](#express-middleware)\n- [Using via Programmatic Interface](#programmatic-interface)\n- [Transformer Notes](#transformer-notes)\n    - [LESS/Stylus](#tn-less-styl)\n    - [ejs](#tn-ejs)\n    - [dust and Handlebars](#tn-dust-hbs)\n\n## Overview\n\nAsset Smasher is a command-line tool, express middleware, and programmatic interface for:\n\n- Pre-processing and transforming files down to plain JavaScript and CSS.\n    - `.coffee` - Compile CoffeeScript into JavaScript\n    - `.ejs` - Run a file through EJS (e.g. to populate configuration parameters into a JavaScript file)\n    - `.less` - Compile Less into CSS\n    - `.styl` - Compile Stylus into CSS\n    - `.hbs` - Precompile Handlebars templates into JavaScript files that register them with `Handlebars.templates`.\n    - `.dust` - Precompile Dust templates into JavaScript files that register them for use with `dust.render`.\n    - Processors can be chained together.  E.g `test.js.hbs.ejs` (run Handlebars template through EJS, then compile it)\n    - Additional processors can be plugged in.\n- Merging files together using Manifest files (`.mf`) with dependency management directives similar to Sprockets.\n    - `require` - Require a single file\n    - `require_dir` - Require all the files in a specific directory\n    - `require_tree` - Require all the files in a specific directory (and subdirectories)\n- Compressing, gzipping, and generating hashed file names.\n    - Compress JavaScript files with `uglify-js`\n    - Compress CSS files with `ycssmin`\n    - Generate Gzipped versions of files\n    - Include a MD5 hash of the file's contents in the file name. `myAsset.js` -> `myAsset-c89cba7b7df028e65cb01d86f4d27077.js`\n        - `asset_path` helper that can be used to reference the hashed name.\n\nIt's released under the [MIT](http://en.wikipedia.org/wiki/MIT_License) license.\n\n## <a name=\"structure-assets\"></a> Structuring Your Assets\n\nAsset Smasher has the concept of \"asset paths\".  These are locations in which your asset files will be located, and from which any relative asset paths will be rooted to.\n\nThe simplest structure has one asset path.\n\nE.g.\n\n    Asset Paths\n    -----------\n     - app\n\n    File Structure\n    --------------\n    app/\n      js/\n      css/\n      images/\n\nA more complicated structure might be\n\n    Asset Paths\n    -----------\n     - app\n     - lib\n     - vendor\n\n    File Structure\n    --------------\n    app/\n      js/\n      css/\n      images/\n    lib/\n      js/\n      css/\n      images/\n    vendor/\n      js/\n      css/\n      images/\n\nBoth of these examples will result in a compiled structure of\n\n    js/\n    css/\n    images/\n\n### <a name=\"manifest-files\"></a> Manifest Files\n\nManifest (`.mf`) files are used to merge many assets into a single resulting file. The file should be named with the resulting file type before the `.mf` extension (e.g. `manifest.css.mf` or `manifest.js.mf`. *Manifest files can `require` other manifest files*\n\nA simple manifest file might look like\n\n    # A comment here\n    require \"./one.js\"\n    require_dir \"./subdir1\"\n    #\n    # Another comment\n    require_tree \"./subdir2\"\n\n**Directives:**\n\n<table border=\"1\" cellpadding=\"5\" cellspacing=\"0\" width=\"100%\">\n <thead>\n  <tr><th width=\"15%\">Directive</th><th width=\"85%\">Description</th></tr>\n </thead>\n <tbody>\n  <tr>\n    <td><code>require \"[path]\"</code></td>\n    <td>\n      <strong>Include a single file</strong>\n      <ul>\n       <li>\n         If the path starts with <code>\"/\"</code>, <code>\"../\"</code>, or <code>\"./\"</code>, process and include the specified file.  The file <em>must</em> be\n         inside one of the configured asset paths.\n       </li>\n       <li>\n         If the path does not start with <code>\"/\"</code>, <code>\"../\"</code>, or <code>\"./\"</code>, the file will be searched for in all of the configured\n         asset paths.  E.g. if there are asset paths <code>one</code> and <code>two</code> defined, <code>require \"js/test.js\"</code>\n         will look for <code>one/js/test.js</code> and then <code>two/js/test.js</code> stopping when it finds a matching file.\n       </li>\n       <li>\n         The filename part of the path does not have to include the whole extension.  E.g <code>require \"test\"</code>\n         finds the first file that matches the name in the asset paths (for example <code>test.js.ejs</code>)\n       </li>\n       <li>\n         If the file does not exist/can't be resolved, it will be ignored (will be logged in verbose mode).\n       </li>\n      </ul>\n    </td>\n  </tr>\n  <tr>\n    <td><code>require_dir \"[path]\"</code></td>\n    <td>\n      <strong>Include all the files in a directory</strong>\n      <ul>\n       <li>\n         The path must be absolute, or relative to the current directory.  E.g. you can do <code>require_dir \"../some/other/dir\"</code>\n         but not <code>require_dir \"somedir\"</code>\n       </li>\n       <li>\n         If using absolute paths, or <code>\"..\"</code> in your paths, the resulting directory needs to be inside one of the configured asset paths.\n       </li>\n       <li>\n         Make sure the directory only contains assets of the type you want.  E.g. for <code>myManifest.js.mf</code>, the dir required had better\n         only contain javascript files, or else bad things will happen.\n       </li>\n       <li>\n         If the directory does not exist, it will be ignored (will be logged in verbose mode).\n       </li>\n      </ul>\n    </td>\n  </tr>\n  <tr>\n    <td><code>require_tree \"[path]\"</code></td>\n    <td>\n      <strong>Include the files in a directory recursively</strong>\n      <ul>\n        <li>The rules for <code>require_tree</code> are the same as the rules for <code>require_dir</code></li>\n      </ul>\n    </td>\n  </tr>\n </tbody>\n</table>\n\n### <a name=\"manifest-directories\"></a> Manifest Directories\n\nIf you create a directory, for example named `foo.js.mf` and put a bunch of javascript files in it (or any subdirectories under it), `asset-smasher` will (recursively) take all the files inside and merge them into `foo.js`.\n\nEssentially, this is a time-saver so that you don't have to create a manifest file that only contains a single `require_tree` directive.\n\n## <a name=\"command-line\"></a> Using via Command-Line\n\nUse `npm install -g asset-smasher` to install the `asset-smasher` command-line tool globally.\n\n      asset-smasher --help\n\n        Usage: asset-smasher [options] <output dir>\n\n        Options:\n\n          -h, --help               output usage information\n          -V, --version            output the version number\n          --compress               compress/minify the generated files\n          --hash                   generate versions of the files with md5 hashes in the name\n          --gzip                   generate gzipped versions of the compiled files\n          --hashVersion <version>  invalidate all assets without changing file contents [1.0]\n          --only <pattern,...>     only process the files matching these glob patterns (relative to any of the paths) [**/*]\n          --paths <path,...>       list of paths to look for assets [.]\n          --prefix <prefix>        prefix to append to logical paths when constructing urls. use if output dir is not served from the root of your web app []\n          --helpers <js_file>      a .js module of helper functions require()s to expose to transforms []\n          --plugins <js_file>      a .js plugin module []\n          --verbose                output more verbose information about what is going on to the console\n          --noclean                do not delete the output directory before generating files (by default it will be removed first)\n\n        If --only is not specified, *all* files in the --paths will be processed.\n        If --hash is specified, a map.json file will be generated that maps the unmangled file name to the hashed one.\n\n        Examples:\n\n          Compile all assets in the current directory to /home/me/compiledAssets\n\n            $ asset-smasher /home/me/compiledAssets\n\n          Something similar to what the Rails asset pipeline does by default\n\n            $ asset-smasher --compress --hash --gzip --prefix /assets \\\n                --paths ./js,./css,./images \\\n                --only **/*.jpg,**/*.gif,**/*.png,application.js.mf,application.css.mf ./public/assets\n\n          Compile assets, providing some custom helpers to the transformation\n\n            $ asset-smasher --helpers helpers.js output\n\n### <a name=\"cli-helpers\"></a> Helpers\n\nThere is a built-in `asset_path` helper that can be used to get the \"real\" (i.e. with hashed file name) path of an asset.  E.g. `asset_path('css/myFile.css')` might return `'/assets/css/myFile-c89cba7b7df028e65cb01d86f4d27077.css`.\n\nSome transformers (e.g. the `.ejs` one) take in a set of local variables that they can use during transformation. You can pass in the path to a JavaScript module whose exports will be included in this set of variables.\n\nYou can use this, for example, to set configuration parameters in your JS files:\n\n**helper.js**\n\n    exports.serviceUrl = 'http://my.service/';\n\n**config.js.ejs**\n\n    //...\n    var serviceUrl = '<%= serviceUrl %>';\n    var cssLocation = '<%= asset_path('css/myFile.css') %>';\n    //...\n\n**Execution**\n\n    $ asset-smasher --helpers helper.js --only config.js.ejs,css/myFile.css .\n    $ cat config.js\n    var serviceUrl = 'http://my.service/';\n    var cssLocation = '/assets/css/myFile-c89cba7b7df028e65cb01d86f4d27077.css';\n\n\n### <a name=\"cli-plugins\"></a> Plugins\n\nIf there's a type of file you want to pre-process that is not natively supported by Asset Smasher, you can add it using a plugin file.\n\nFor an example of what the transformer classes look like, look in the `lib/compilation/transforms` directory\n\nIf a plugin module is passed (via `--plugins`), it will be `require()`d and then invoked, being passed in the asset smasher library (the module defined in `lib/asset-smasher.js`)\n\nTo register your transformer, just add another entry to the `transforms` object.\n\nE.g.\n\n**my_plugin.js**\n\n    module.exports = function(assetSmasher) {\n       // A stupid transformer that adds \"foo\" to the start and end of the contents\n       var FooTransform = function FooTransform(options) {\n         this.options = options || {};\n       };\n       FooTransform.prototype = {\n         extensions:function () {\n           return ['.foo'];\n         },\n         shouldTransform:function (file) {\n           return path.extname(file) === '.foo';\n         },\n         transformedFileName:function (file) {\n           return path.basename(file, '.foo');\n         },\n         transform:function (asset, cb) {\n           // Transform the file name\n           asset.logicalName = this.transformedFileName(asset.logicalName);\n           // Get the contents\n           var contents = asset.contents;\n           if (Buffer.isBuffer(contents)) {\n             contents = contents.toString('utf-8');\n           }\n           // Compile the contents\n           asset.contents = 'foo-' + contents + '-foo';\n           cb();\n         }\n       };\n\n       assetSmasher.transforms.Foo = FooTransform;\n    };\n\nIf you then invoke `asset-smasher` with `--plugins my_plugin.js` it will automatically transform `*.foo` files.\n\n## <a name=\"express-middleware\"></a> Using via Express Middleware\n\nAsset smasher exposes an `express` middleware that can:\n\n- Serve your assets un-merged/mangled in development mode.\n- Serve precompiled assets (with hashed file names) in production mode.\n\nThe middleware takes in the same arguments as the `Smasher` constructor, with a few extras:\n\n- `serve` - boolean (or object - see more below) indiacating whether the middleware should serve the asset files.  Usualy set this to `true` in development, `false` in production (e.g if you're using precompiled assets)\n    - An object can be passed in with the following properties to control the serving behavior. If `true` is passed in, the default values here will be used\n        - `individual` - Whether the individual (`true`) or merged files (`false`) should be served. Default `true`.\n- `assetMapLocation` - path to the `map.json` generated by the command-line `asset-smasher` util.  This allows the helper methods to determine what the hashed file names were\n\nThe middleware exposes two helpers to your views:\n\n- `js_asset(logicalPath)` - Render a `<script>` tag for the specified JS asset. When `serve` is true, this will \"explode\" manifests and write out a separate `<script>` for each required file.  This makes debugging much easier.\n- `css_asset(logicalPath)` - Render a `<link>` tag for the specified CSS asset.  Same thing happens when `serve` is true as with `js_asset`.\n- `raw_asset(logicalPath)` - Return the path to the asset.\n\nYou *must* include the middleware **before** the Express routing middleware. Otherwise the asset helper functions will not be available for your view to use.\n\n### Example\n\n    var assetSmasher = require('asset-smasher');\n\n**Middleware config (Dev)**\n\n    app.use(assetSmasher.middleware({\n      serve: true,\n      paths: [path.join(__dirname, 'assetDir1'), path.join(__dirname, 'assetDir2')],\n      prefix: '/assets',\n      outputTo: path.join(__dirname, 'tmp')\n    }));\n\n**Middleware config (Prod)**\n\n    app.use(assetSmasher.middleware({\n      serve: false,\n      prefix: '/assets',\n      assetMapLocation: path.join(__dirname, 'public/assets/map.json')\n    }));\n\n**Middleware config (Alternate Prod config not using precompilation, but instead compile on first access)**\n\nNote that if you use this configuration, you will **not** be able to use \"hashed\" filenames.\n\n    app.use(express.staticCache());\n    app.use(express.static(path.join(__dirname, 'public')));\n    app.use(assetSmasher.middleware({\n      serve: {\n        individual: false\n      },\n      paths: [path.join(__dirname, 'assetDir1'), path.join(__dirname, 'assetDir2')],\n      compress: true,\n      prefix: '/assets',\n      // This will make the files be served once by asset smasher\n      // and then by the express \"static\" middleware thereafter.\n      // You can then also use something like \"staticCache\" to cache the files if you're not\n      // using a reverse proxy cache on the public dir\n      outputTo: path.join(__dirname, 'public/assets')\n    }));\n\n**View (ejs here, but could be others)**\n\n    <!DOCTYPE html>\n    <html>\n    <head>\n      <title>Test</title>\n      <%- css_asset('application.css') %>\n      <%- js_asset('application.js') %>\n    </head>\n    <body>\n      This is a test\n    </body>\n    </html>\n\n## <a name=\"programmatic-interface\"></a> Using via Programmatic Interface\n\nYou can invoke Asset Smasher programmatically by `require`ing it.  You can also plug in additional transformers this way.\n\nThe `Smasher` object has the following methods:\n\n - `compileAssets(cb)` - Find and compile all the assets.\n - `compileSingleAsset(assetFilePath, cb)` - Compile a single asset (assetFilePath is the actual path to the file, not a logical path)\n - `findAssets(cb)` - Find, but don't compile the assets.  Good for determining dependency graph without compiling.\n - `getAssetByLogicalPath(logicalPath)` - Get information about an asset by its logical path.  Only call this after finding/compiling assets.\n - `getHashedFileMapping()` - When `hash` is true, this returns a mapping of logical path to \"hashed\" logical path.  This object is what the command-line tool outputs to `map.json`. Only call this after finding/compiling assets.\n - `getRequiredLogicalPathsFor(asset)` - Get the logical paths of the assets that should be merged into the specified asset (populated for `.mf` files). Only call this after finding/compiling assets.\n - `getProcessingOrderLogicalPaths()` - Get a list of the order in which assets should be processed in order to satisfy all dependencies. Only call this after finding/compiling assets.\n - `reset()` - Reset the asset metadata.\n\nThe `Asset` object returned by `getAssetByLogicalPath` has the following properties (and one method):\n\n - `logicalPath` - The logical path\n - `hashedPath` - If `hash` is true, the hashed filename path, otherwise the same as `logicalPath`\n - `assetFilePath` - The full path to the actual source asset\n - `compiled` - Whether the asset has been compiled\n - `compiledAssetFilePath` - The full path to the compiled asset file\n - `reset()` - Set the asset back to its before-compile state (clear out contents, set name back to pre-transform name)\n\n**Example**\n\n    var assetSmasher = require('asset-smasher');\n    var Smasher = assetSmasher.Smasher;\n\n    // Plug in a custom transformer\n    assetSmasher.transforms['MyAwesomeFormat'] = require('myAwesomeFormatTransformer');\n\n    var sm = new Smasher({\n      paths:['/path/one', '/path/two'],\n      only:['**/*.{jpg,gif,png}', 'application.js.mf', 'application.css.mf'],\n      prefix:'/assets',\n      compress:true,\n      hash:true,\n      hashVersion:'1.0',\n      gzip:true,\n      outputTo:__dirname + '/public/assets',\n      helpers:{\n       my: 'helper',\n       another: 'helper'\n      },\n      verbose:true,\n      noclean:true\n    });\n    sm.compileAssets(function(err) {\n      if(err) {\n        console.log('An error occurred', err);\n      } else {\n        console.log('Compilation done!');\n      }\n    });\n\n## <a name=\"transformer-notes\"></a> Transformer Notes\n\n### <a name=\"tn-less-styl\"></a> LESS/Stylus\n\n- Any `@include/@import` paths are *relative to the path that the file is in*.\n- Any `@include/@import`ed files will *not* be processed individually by Asset Smasher (i.e. you can't `@include` a LESS file that is preprocessed by ejs)\n\n### <a name=\"tn-ejs\"></a> ejs\n\n- Any registered helpers will be exposed as global variables to the `ejs` transform.\n- The built-in `asset_paths` helper can be used here.\n\n### <a name=\"tn-dust-hbs\"></a> dust and Handlebars\n\n- The name of the template will be the template's \"logical path\" (minus the asset path it is in), minus the `.js.dust` or `.js.hbs` file extension.\n    - E.g. `/my/templates/test.js.dust`'s template name will be `test` (assuming `/my/templates` is the asset path)\n","readmeFilename":"README.md","_id":"asset-smasher@0.2.9","dist":{"shasum":"2a2304ec5431e60514b2f49abfbe7df9aceea9f7","tarball":"https://registry.npmjs.org/asset-smasher/-/asset-smasher-0.2.9.tgz","integrity":"sha512-rx3pDmZO6Gx5R0ZUiBQd6wS3YjJsJhTLMjl7K/bF72U9q6mRHeiWWP4KunO01vxVKcnXzexsci2ZhRE/JYtp0Q==","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEQCICTVGC1NkXIa7r5f/au7iIAdXsKQXQTH0PvbwZcAjuMCAiBezUmpF3x62s5aU0DnVgRNYzuj68oy0PTR8RTJ88OLRw=="}]},"_from":".","_npmVersion":"1.2.18","_npmUser":{"name":"jriecken","email":"jriecken@gmail.com"},"maintainers":[{"name":"jriecken","email":"jriecken@gmail.com"}]},"0.2.10":{"name":"asset-smasher","description":"Asset pre-processor, merger, and compressor.","version":"0.2.10","author":{"name":"Jim Riecken","email":"jriecken@gmail.com"},"keywords":["asset","compress","merge","preprocess"],"license":{"type":"MIT","url":"http://github.com/jriecken/asset-smasher/raw/master/LICENSE"},"repository":{"type":"git","url":"git://github.com/jriecken/asset-smasher.git"},"bugs":{"url":"http://github.com/jriecken/asset-smasher/issues"},"main":"./lib/asset-smasher.js","bin":{"asset-smasher":"./bin/asset-smasher"},"dependencies":{"async":"0.2.6","commander":"1.1.1","glob":"3.1.21","mkdirp":"0.3.5","minimatch":"0.2.11","rimraf":"2.1.4","send":"0.1.0","uglify-js":"2.2.5","underscore":"1.4.4","ycssmin":"1.0.1"},"optionalDependencies":{},"devDependencies":{},"engines":{"node":">= 0.6.0"},"readme":"# Asset Smasher\n\nAsset pre-processor, merger, and compressor for Node.js\n\n- [Structuring Your Assets](#structure-assets)\n    - [Manifest Files](#manifest-files)\n    - [Manifest Directories](#manifest-directories)\n- [Using via Command Line](#command-line)\n    - [Helpers](#cli-helpers)\n    - [Plugins](#cli-plugins)\n- [Using via Express Middleware](#express-middleware)\n- [Using via Programmatic Interface](#programmatic-interface)\n- [Transformer Notes](#transformer-notes)\n    - [LESS/Stylus](#tn-less-styl)\n    - [ejs](#tn-ejs)\n    - [dust and Handlebars](#tn-dust-hbs)\n\n## Overview\n\nAsset Smasher is a command-line tool, express middleware, and programmatic interface for:\n\n- Pre-processing and transforming files down to plain JavaScript and CSS.\n    - `.coffee` - Compile CoffeeScript into JavaScript\n    - `.ejs` - Run a file through EJS (e.g. to populate configuration parameters into a JavaScript file)\n    - `.less` - Compile Less into CSS\n    - `.styl` - Compile Stylus into CSS\n    - `.hbs` - Precompile Handlebars templates into JavaScript files that register them with `Handlebars.templates`.\n    - `.dust` - Precompile Dust templates into JavaScript files that register them for use with `dust.render`.\n    - Processors can be chained together.  E.g `test.js.hbs.ejs` (run Handlebars template through EJS, then compile it)\n    - Additional processors can be plugged in.\n- Merging files together using Manifest files (`.mf`) with dependency management directives similar to Sprockets.\n    - `require` - Require a single file\n    - `require_dir` - Require all the files in a specific directory\n    - `require_tree` - Require all the files in a specific directory (and subdirectories)\n- Compressing, gzipping, and generating hashed file names.\n    - Compress JavaScript files with `uglify-js`\n    - Compress CSS files with `ycssmin`\n    - Generate Gzipped versions of files\n    - Include a MD5 hash of the file's contents in the file name. `myAsset.js` -> `myAsset-c89cba7b7df028e65cb01d86f4d27077.js`\n        - `asset_path` helper that can be used to reference the hashed name.\n\nIt's released under the [MIT](http://en.wikipedia.org/wiki/MIT_License) license.\n\n## <a name=\"structure-assets\"></a> Structuring Your Assets\n\nAsset Smasher has the concept of \"asset paths\".  These are locations in which your asset files will be located, and from which any relative asset paths will be rooted to.\n\nThe simplest structure has one asset path.\n\nE.g.\n\n    Asset Paths\n    -----------\n     - app\n\n    File Structure\n    --------------\n    app/\n      js/\n      css/\n      images/\n\nA more complicated structure might be\n\n    Asset Paths\n    -----------\n     - app\n     - lib\n     - vendor\n\n    File Structure\n    --------------\n    app/\n      js/\n      css/\n      images/\n    lib/\n      js/\n      css/\n      images/\n    vendor/\n      js/\n      css/\n      images/\n\nBoth of these examples will result in a compiled structure of\n\n    js/\n    css/\n    images/\n\n### <a name=\"manifest-files\"></a> Manifest Files\n\nManifest (`.mf`) files are used to merge many assets into a single resulting file. The file should be named with the resulting file type before the `.mf` extension (e.g. `manifest.css.mf` or `manifest.js.mf`. *Manifest files can `require` other manifest files*\n\nOnly files that will be transformed down to a file of a manifest's \"type\" (e.g. `manifest.css.mf` => `.css`, `manifest.js.mf` => `.js`) will be included. This means that, for example, if you `require_dir` a directory in a JavaScript manifest that happens to contain both JavaScript and CSS, only the JavaScript files will be required.\n\nA simple manifest file might look like\n\n    # A comment here\n    require \"./one.js\"\n    require_dir \"./subdir1\"\n    #\n    # Another comment\n    require_tree \"./subdir2\"\n\n**Directives:**\n\n<table border=\"1\" cellpadding=\"5\" cellspacing=\"0\" width=\"100%\">\n <thead>\n  <tr><th width=\"15%\">Directive</th><th width=\"85%\">Description</th></tr>\n </thead>\n <tbody>\n  <tr>\n    <td><code>require \"[path]\"</code></td>\n    <td>\n      <strong>Include a single file</strong>\n      <ul>\n       <li>\n         If the path starts with <code>\"/\"</code>, <code>\"../\"</code>, or <code>\"./\"</code>, process and include the specified file.  The file <em>must</em> be\n         inside one of the configured asset paths.\n       </li>\n       <li>\n         If the path does not start with <code>\"/\"</code>, <code>\"../\"</code>, or <code>\"./\"</code>, the file will be searched for in all of the configured\n         asset paths.  E.g. if there are asset paths <code>one</code> and <code>two</code> defined, <code>require \"js/test.js\"</code>\n         will look for <code>one/js/test.js</code> and then <code>two/js/test.js</code> stopping when it finds a matching file.\n       </li>\n       <li>\n         The filename part of the path does not have to include the whole extension.  E.g <code>require \"test\"</code>\n         finds the first file that matches the name in the asset paths (for example <code>test.js.ejs</code>)\n       </li>\n       <li>\n         If the file does not exist/can't be resolved/isn't of the right type for the manifest, it will be ignored (will be logged in verbose mode).\n       </li>\n      </ul>\n    </td>\n  </tr>\n  <tr>\n    <td><code>require_dir \"[path]\"</code></td>\n    <td>\n      <strong>Include all the files in a directory</strong>\n      <ul>\n       <li>\n         The path must be absolute, or relative to the current directory.  E.g. you can do <code>require_dir \"../some/other/dir\"</code>\n         but not <code>require_dir \"somedir\"</code>\n       </li>\n       <li>\n         If using absolute paths, or <code>\"..\"</code> in your paths, the resulting directory needs to be inside one of the configured asset paths.\n       </li>\n       <li>\n         If the directory does not exist, it will be ignored (will be logged in verbose mode).\n       </li>\n      </ul>\n    </td>\n  </tr>\n  <tr>\n    <td><code>require_tree \"[path]\"</code></td>\n    <td>\n      <strong>Include the files in a directory recursively</strong>\n      <ul>\n        <li>The rules for <code>require_tree</code> are the same as the rules for <code>require_dir</code></li>\n      </ul>\n    </td>\n  </tr>\n </tbody>\n</table>\n\n### <a name=\"manifest-directories\"></a> Manifest Directories\n\nIf you create a directory, for example named `foo.js.mf` and put a bunch of javascript files in it (or any subdirectories under it), `asset-smasher` will (recursively) take all the files inside and merge them into `foo.js`.\n\nEssentially, this is a time-saver so that you don't have to create a manifest file that only contains a single `require_tree` directive.\n\n## <a name=\"command-line\"></a> Using via Command-Line\n\nUse `npm install -g asset-smasher` to install the `asset-smasher` command-line tool globally.\n\n      asset-smasher --help\n\n        Usage: asset-smasher [options] <output dir>\n\n        Options:\n\n          -h, --help               output usage information\n          -V, --version            output the version number\n          --compress               compress/minify the generated files\n          --hash                   generate versions of the files with md5 hashes in the name\n          --gzip                   generate gzipped versions of the compiled files\n          --hashVersion <version>  invalidate all assets without changing file contents [1.0]\n          --only <pattern,...>     only process the files matching these glob patterns (relative to any of the paths) [**/*]\n          --paths <path,...>       list of paths to look for assets [.]\n          --prefix <prefix>        prefix to append to logical paths when constructing urls. use if output dir is not served from the root of your web app []\n          --helpers <js_file>      a .js module of helper functions require()s to expose to transforms []\n          --plugins <js_file>      a .js plugin module []\n          --verbose                output more verbose information about what is going on to the console\n          --noclean                do not delete the output directory before generating files (by default it will be removed first)\n\n        If --only is not specified, *all* files in the --paths will be processed.\n        If --hash is specified, a map.json file will be generated that maps the unmangled file name to the hashed one.\n\n        Examples:\n\n          Compile all assets in the current directory to /home/me/compiledAssets\n\n            $ asset-smasher /home/me/compiledAssets\n\n          Something similar to what the Rails asset pipeline does by default\n\n            $ asset-smasher --compress --hash --gzip --prefix /assets \\\n                --paths ./js,./css,./images \\\n                --only **/*.jpg,**/*.gif,**/*.png,application.js.mf,application.css.mf ./public/assets\n\n          Compile assets, providing some custom helpers to the transformation\n\n            $ asset-smasher --helpers helpers.js output\n\n### <a name=\"cli-helpers\"></a> Helpers\n\nThere is a built-in `asset_path` helper that can be used to get the \"real\" (i.e. with hashed file name) path of an asset.  E.g. `asset_path('css/myFile.css')` might return `'/assets/css/myFile-c89cba7b7df028e65cb01d86f4d27077.css`.\n\nSome transformers (e.g. the `.ejs` one) take in a set of local variables that they can use during transformation. You can pass in the path to a JavaScript module whose exports will be included in this set of variables.\n\nYou can use this, for example, to set configuration parameters in your JS files:\n\n**helper.js**\n\n    exports.serviceUrl = 'http://my.service/';\n\n**config.js.ejs**\n\n    //...\n    var serviceUrl = '<%= serviceUrl %>';\n    var cssLocation = '<%= asset_path('css/myFile.css') %>';\n    //...\n\n**Execution**\n\n    $ asset-smasher --helpers helper.js --only config.js.ejs,css/myFile.css .\n    $ cat config.js\n    var serviceUrl = 'http://my.service/';\n    var cssLocation = '/assets/css/myFile-c89cba7b7df028e65cb01d86f4d27077.css';\n\n\n### <a name=\"cli-plugins\"></a> Plugins\n\nIf there's a type of file you want to pre-process that is not natively supported by Asset Smasher, you can add it using a plugin file.\n\nFor an example of what the transformer classes look like, look in the `lib/compilation/transforms` directory\n\nIf a plugin module is passed (via `--plugins`), it will be `require()`d and then invoked, being passed in the asset smasher library (the module defined in `lib/asset-smasher.js`)\n\nTo register your transformer, just add another entry to the `transforms` object.\n\nE.g.\n\n**my_plugin.js**\n\n    module.exports = function(assetSmasher) {\n       // A stupid transformer that adds \"foo\" to the start and end of the contents\n       var FooTransform = function FooTransform(options) {\n         this.options = options || {};\n       };\n       FooTransform.prototype = {\n         extensions:function () {\n           return ['.foo'];\n         },\n         shouldTransform:function (file) {\n           return path.extname(file) === '.foo';\n         },\n         transformedFileName:function (file) {\n           return path.basename(file, '.foo');\n         },\n         transform:function (asset, cb) {\n           // Transform the file name\n           asset.logicalName = this.transformedFileName(asset.logicalName);\n           // Get the contents\n           var contents = asset.contents;\n           if (Buffer.isBuffer(contents)) {\n             contents = contents.toString('utf-8');\n           }\n           // Compile the contents\n           asset.contents = 'foo-' + contents + '-foo';\n           cb();\n         }\n       };\n\n       assetSmasher.transforms.Foo = FooTransform;\n    };\n\nIf you then invoke `asset-smasher` with `--plugins my_plugin.js` it will automatically transform `*.foo` files.\n\n## <a name=\"express-middleware\"></a> Using via Express Middleware\n\nAsset smasher exposes an `express` middleware that can:\n\n- Serve your assets un-merged/mangled in development mode.\n- Serve precompiled assets (with hashed file names) in production mode.\n\nThe middleware takes in the same arguments as the `Smasher` constructor, with a few extras:\n\n- `serve` - boolean (or object - see more below) indiacating whether the middleware should serve the asset files.  Usualy set this to `true` in development, `false` in production (e.g if you're using precompiled assets)\n    - An object can be passed in with the following properties to control the serving behavior. If `true` is passed in, the default values here will be used\n        - `individual` - Whether the individual (`true`) or merged files (`false`) should be served. Default `true`.\n- `assetMapLocation` - path to the `map.json` generated by the command-line `asset-smasher` util.  This allows the helper methods to determine what the hashed file names were\n\nThe middleware exposes two helpers to your views:\n\n- `js_asset(logicalPath)` - Render a `<script>` tag for the specified JS asset. When `serve` is true, this will \"explode\" manifests and write out a separate `<script>` for each required file.  This makes debugging much easier.\n- `css_asset(logicalPath)` - Render a `<link>` tag for the specified CSS asset.  Same thing happens when `serve` is true as with `js_asset`.\n- `raw_asset(logicalPath)` - Return the path to the asset.\n\nYou *must* include the middleware **before** the Express routing middleware. Otherwise the asset helper functions will not be available for your view to use.\n\n### Example\n\n    var assetSmasher = require('asset-smasher');\n\n**Middleware config (Dev)**\n\n    app.use(assetSmasher.middleware({\n      serve: true,\n      paths: [path.join(__dirname, 'assetDir1'), path.join(__dirname, 'assetDir2')],\n      prefix: '/assets',\n      outputTo: path.join(__dirname, 'tmp')\n    }));\n\n**Middleware config (Prod)**\n\n    app.use(assetSmasher.middleware({\n      serve: false,\n      prefix: '/assets',\n      assetMapLocation: path.join(__dirname, 'public/assets/map.json')\n    }));\n\n**Middleware config (Alternate Prod config not using precompilation, but instead compile on first access)**\n\nNote that if you use this configuration, you will **not** be able to use \"hashed\" filenames.\n\n    app.use(express.staticCache());\n    app.use(express.static(path.join(__dirname, 'public')));\n    app.use(assetSmasher.middleware({\n      serve: {\n        individual: false\n      },\n      paths: [path.join(__dirname, 'assetDir1'), path.join(__dirname, 'assetDir2')],\n      compress: true,\n      prefix: '/assets',\n      // This will make the files be served once by asset smasher\n      // and then by the express \"static\" middleware thereafter.\n      // You can then also use something like \"staticCache\" to cache the files if you're not\n      // using a reverse proxy cache on the public dir\n      outputTo: path.join(__dirname, 'public/assets')\n    }));\n\n**View (ejs here, but could be others)**\n\n    <!DOCTYPE html>\n    <html>\n    <head>\n      <title>Test</title>\n      <%- css_asset('application.css') %>\n      <%- js_asset('application.js') %>\n    </head>\n    <body>\n      This is a test\n    </body>\n    </html>\n\n## <a name=\"programmatic-interface\"></a> Using via Programmatic Interface\n\nYou can invoke Asset Smasher programmatically by `require`ing it.  You can also plug in additional transformers this way.\n\nThe `Smasher` object has the following methods:\n\n - `compileAssets(cb)` - Find and compile all the assets.\n - `compileSingleAsset(assetFilePath, cb)` - Compile a single asset (assetFilePath is the actual path to the file, not a logical path)\n - `findAssets(cb)` - Find, but don't compile the assets.  Good for determining dependency graph without compiling.\n - `getAssetByLogicalPath(logicalPath)` - Get information about an asset by its logical path.  Only call this after finding/compiling assets.\n - `getHashedFileMapping()` - When `hash` is true, this returns a mapping of logical path to \"hashed\" logical path.  This object is what the command-line tool outputs to `map.json`. Only call this after finding/compiling assets.\n - `getRequiredLogicalPathsFor(asset)` - Get the logical paths of the assets that should be merged into the specified asset (populated for `.mf` files). Only call this after finding/compiling assets.\n - `getProcessingOrderLogicalPaths()` - Get a list of the order in which assets should be processed in order to satisfy all dependencies. Only call this after finding/compiling assets.\n - `reset()` - Reset the asset metadata.\n\nThe `Asset` object returned by `getAssetByLogicalPath` has the following properties (and one method):\n\n - `logicalPath` - The logical path\n - `hashedPath` - If `hash` is true, the hashed filename path, otherwise the same as `logicalPath`\n - `assetFilePath` - The full path to the actual source asset\n - `compiled` - Whether the asset has been compiled\n - `compiledAssetFilePath` - The full path to the compiled asset file\n - `reset()` - Set the asset back to its before-compile state (clear out contents, set name back to pre-transform name)\n\n**Example**\n\n    var assetSmasher = require('asset-smasher');\n    var Smasher = assetSmasher.Smasher;\n\n    // Plug in a custom transformer\n    assetSmasher.transforms['MyAwesomeFormat'] = require('myAwesomeFormatTransformer');\n\n    var sm = new Smasher({\n      paths:['/path/one', '/path/two'],\n      only:['**/*.{jpg,gif,png}', 'application.js.mf', 'application.css.mf'],\n      prefix:'/assets',\n      compress:true,\n      hash:true,\n      hashVersion:'1.0',\n      gzip:true,\n      outputTo:__dirname + '/public/assets',\n      helpers:{\n       my: 'helper',\n       another: 'helper'\n      },\n      verbose:true,\n      noclean:true\n    });\n    sm.compileAssets(function(err) {\n      if(err) {\n        console.log('An error occurred', err);\n      } else {\n        console.log('Compilation done!');\n      }\n    });\n\n## <a name=\"transformer-notes\"></a> Transformer Notes\n\n### <a name=\"tn-less-styl\"></a> LESS/Stylus\n\n- Any `@include/@import` paths are *relative to the path that the file is in*.\n- Any `@include/@import`ed files will *not* be processed individually by Asset Smasher (i.e. you can't `@include` a LESS file that is preprocessed by ejs)\n\n### <a name=\"tn-ejs\"></a> ejs\n\n- Any registered helpers will be exposed as global variables to the `ejs` transform.\n- The built-in `asset_paths` helper can be used here.\n\n### <a name=\"tn-dust-hbs\"></a> dust and Handlebars\n\n- The name of the template will be the template's \"logical path\" (minus the asset path it is in), minus the `.js.dust` or `.js.hbs` file extension.\n    - E.g. `/my/templates/test.js.dust`'s template name will be `test` (assuming `/my/templates` is the asset path)\n","readmeFilename":"README.md","_id":"asset-smasher@0.2.10","dist":{"shasum":"a2a2d79f6d0e79f60b98f5cb367754cf874bcecd","tarball":"https://registry.npmjs.org/asset-smasher/-/asset-smasher-0.2.10.tgz","integrity":"sha512-OW7sqKQ5ng35rgjLuKXUOlkiJR/h8YRelf97WsSltShgy4mU7XbdBw7/krew2LL+g3r0TXbrQmftoBS1c8rjEA==","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEYCIQD4Smhk4OCRbdrsuMbkErIJHEuqhF2qTcFy4F1CPb4DOgIhALG8id7SHM5ENKy3VcAuXXiSyp7lifxNj8Dgf+sOW8ci"}]},"_from":".","_npmVersion":"1.2.18","_npmUser":{"name":"jriecken","email":"jriecken@gmail.com"},"maintainers":[{"name":"jriecken","email":"jriecken@gmail.com"}]},"0.2.11":{"name":"asset-smasher","description":"Asset pre-processor, merger, and compressor.","version":"0.2.11","author":{"name":"Jim Riecken","email":"jriecken@gmail.com"},"keywords":["asset","compress","merge","preprocess"],"license":{"type":"MIT","url":"http://github.com/jriecken/asset-smasher/raw/master/LICENSE"},"repository":{"type":"git","url":"git://github.com/jriecken/asset-smasher.git"},"bugs":{"url":"http://github.com/jriecken/asset-smasher/issues"},"main":"./lib/asset-smasher.js","bin":{"asset-smasher":"./bin/asset-smasher"},"dependencies":{"async":"0.2.6","commander":"1.1.1","dependency-graph":"0.1.0","glob":"3.1.21","mkdirp":"0.3.5","minimatch":"0.2.11","rimraf":"2.1.4","send":"0.1.0","uglify-js":"2.2.5","underscore":"1.4.4","ycssmin":"1.0.1"},"optionalDependencies":{},"devDependencies":{},"engines":{"node":">= 0.6.0"},"readme":"# Asset Smasher\n\nAsset pre-processor, merger, and compressor for Node.js\n\n- [Structuring Your Assets](#structure-assets)\n    - [Manifest Files](#manifest-files)\n    - [Manifest Directories](#manifest-directories)\n- [Using via Command Line](#command-line)\n    - [Helpers](#cli-helpers)\n    - [Plugins](#cli-plugins)\n- [Using via Express Middleware](#express-middleware)\n- [Using via Programmatic Interface](#programmatic-interface)\n- [Transformer Notes](#transformer-notes)\n    - [LESS/Stylus](#tn-less-styl)\n    - [ejs](#tn-ejs)\n    - [dust and Handlebars](#tn-dust-hbs)\n\n## Overview\n\nAsset Smasher is a command-line tool, express middleware, and programmatic interface for:\n\n- Pre-processing and transforming files down to plain JavaScript and CSS.\n    - `.coffee` - Compile CoffeeScript into JavaScript\n    - `.ejs` - Run a file through EJS (e.g. to populate configuration parameters into a JavaScript file)\n    - `.less` - Compile Less into CSS\n    - `.styl` - Compile Stylus into CSS\n    - `.hbs` - Precompile Handlebars templates into JavaScript files that register them with `Handlebars.templates`.\n    - `.dust` - Precompile Dust templates into JavaScript files that register them for use with `dust.render`.\n    - Processors can be chained together.  E.g `test.js.hbs.ejs` (run Handlebars template through EJS, then compile it)\n    - Additional processors can be plugged in.\n- Merging files together using Manifest files (`.mf`) with dependency management directives similar to Sprockets.\n    - `require` - Require a single file\n    - `require_dir` - Require all the files in a specific directory\n    - `require_tree` - Require all the files in a specific directory (and subdirectories)\n- Compressing, gzipping, and generating hashed file names.\n    - Compress JavaScript files with `uglify-js`\n    - Compress CSS files with `ycssmin`\n    - Generate Gzipped versions of files\n    - Include a MD5 hash of the file's contents in the file name. `myAsset.js` -> `myAsset-c89cba7b7df028e65cb01d86f4d27077.js`\n        - `asset_path` helper that can be used to reference the hashed name.\n\nIt's released under the [MIT](http://en.wikipedia.org/wiki/MIT_License) license.\n\n## <a name=\"structure-assets\"></a> Structuring Your Assets\n\nAsset Smasher has the concept of \"asset paths\".  These are locations in which your asset files will be located, and from which any relative asset paths will be rooted to.\n\nThe simplest structure has one asset path.\n\nE.g.\n\n    Asset Paths\n    -----------\n     - app\n\n    File Structure\n    --------------\n    app/\n      js/\n      css/\n      images/\n\nA more complicated structure might be\n\n    Asset Paths\n    -----------\n     - app\n     - lib\n     - vendor\n\n    File Structure\n    --------------\n    app/\n      js/\n      css/\n      images/\n    lib/\n      js/\n      css/\n      images/\n    vendor/\n      js/\n      css/\n      images/\n\nBoth of these examples will result in a compiled structure of\n\n    js/\n    css/\n    images/\n\n### <a name=\"manifest-files\"></a> Manifest Files\n\nManifest (`.mf`) files are used to merge many assets into a single resulting file. The file should be named with the resulting file type before the `.mf` extension (e.g. `manifest.css.mf` or `manifest.js.mf`. *Manifest files can `require` other manifest files*\n\nOnly files that will be transformed down to a file of a manifest's \"type\" (e.g. `manifest.css.mf` => `.css`, `manifest.js.mf` => `.js`) will be included. This means that, for example, if you `require_dir` a directory in a JavaScript manifest that happens to contain both JavaScript and CSS, only the JavaScript files will be required.\n\nA simple manifest file might look like\n\n    # A comment here\n    require \"./one.js\"\n    require_dir \"./subdir1\"\n    #\n    # Another comment\n    require_tree \"./subdir2\"\n\n**Directives:**\n\n<table border=\"1\" cellpadding=\"5\" cellspacing=\"0\" width=\"100%\">\n <thead>\n  <tr><th width=\"15%\">Directive</th><th width=\"85%\">Description</th></tr>\n </thead>\n <tbody>\n  <tr>\n    <td><code>require \"[path]\"</code></td>\n    <td>\n      <strong>Include a single file</strong>\n      <ul>\n       <li>\n         If the path starts with <code>\"/\"</code>, <code>\"../\"</code>, or <code>\"./\"</code>, process and include the specified file.  The file <em>must</em> be\n         inside one of the configured asset paths.\n       </li>\n       <li>\n         If the path does not start with <code>\"/\"</code>, <code>\"../\"</code>, or <code>\"./\"</code>, the file will be searched for in all of the configured\n         asset paths.  E.g. if there are asset paths <code>one</code> and <code>two</code> defined, <code>require \"js/test.js\"</code>\n         will look for <code>one/js/test.js</code> and then <code>two/js/test.js</code> stopping when it finds a matching file.\n       </li>\n       <li>\n         The filename part of the path does not have to include the whole extension.  E.g <code>require \"test\"</code>\n         finds the first file that matches the name in the asset paths (for example <code>test.js.ejs</code>)\n       </li>\n       <li>\n         If the file does not exist/can't be resolved/isn't of the right type for the manifest, it will be ignored (will be logged in verbose mode).\n       </li>\n      </ul>\n    </td>\n  </tr>\n  <tr>\n    <td><code>require_dir \"[path]\"</code></td>\n    <td>\n      <strong>Include all the files in a directory</strong>\n      <ul>\n       <li>\n         The path must be absolute, or relative to the current directory.  E.g. you can do <code>require_dir \"../some/other/dir\"</code>\n         but not <code>require_dir \"somedir\"</code>\n       </li>\n       <li>\n         If using absolute paths, or <code>\"..\"</code> in your paths, the resulting directory needs to be inside one of the configured asset paths.\n       </li>\n       <li>\n         If the directory does not exist, it will be ignored (will be logged in verbose mode).\n       </li>\n      </ul>\n    </td>\n  </tr>\n  <tr>\n    <td><code>require_tree \"[path]\"</code></td>\n    <td>\n      <strong>Include the files in a directory recursively</strong>\n      <ul>\n        <li>The rules for <code>require_tree</code> are the same as the rules for <code>require_dir</code></li>\n      </ul>\n    </td>\n  </tr>\n </tbody>\n</table>\n\n### <a name=\"manifest-directories\"></a> Manifest Directories\n\nIf you create a directory, for example named `foo.js.mf` and put a bunch of javascript files in it (or any subdirectories under it), `asset-smasher` will (recursively) take all the files inside and merge them into `foo.js`.\n\nEssentially, this is a time-saver so that you don't have to create a manifest file that only contains a single `require_tree` directive.\n\n## <a name=\"command-line\"></a> Using via Command-Line\n\nUse `npm install -g asset-smasher` to install the `asset-smasher` command-line tool globally.\n\n      asset-smasher --help\n\n        Usage: asset-smasher [options] <output dir>\n\n        Options:\n\n          -h, --help               output usage information\n          -V, --version            output the version number\n          --compress               compress/minify the generated files\n          --hash                   generate versions of the files with md5 hashes in the name\n          --gzip                   generate gzipped versions of the compiled files\n          --hashVersion <version>  invalidate all assets without changing file contents [1.0]\n          --only <pattern,...>     only process the files matching these glob patterns (relative to any of the paths) [**/*]\n          --paths <path,...>       list of paths to look for assets [.]\n          --prefix <prefix>        prefix to append to logical paths when constructing urls. use if output dir is not served from the root of your web app []\n          --helpers <js_file>      a .js module of helper functions require()s to expose to transforms []\n          --plugins <js_file>      a .js plugin module []\n          --verbose                output more verbose information about what is going on to the console\n          --noclean                do not delete the output directory before generating files (by default it will be removed first)\n\n        If --only is not specified, *all* files in the --paths will be processed.\n        If --hash is specified, a map.json file will be generated that maps the unmangled file name to the hashed one.\n\n        Be careful that your shell doesn't expand glob patterns when passing them as arguments. To be safe, surround the argument with quotes.\n\n        Examples:\n\n          Compile all assets in the current directory to /home/me/compiledAssets\n\n            $ asset-smasher /home/me/compiledAssets\n\n          Something similar to what the Rails asset pipeline does by default\n\n            $ asset-smasher --compress --hash --gzip --prefix /assets \\\n                --paths ./js,./css,./images \\\n                --only \"**/*.jpg,**/*.gif,**/*.png,application.js.mf,application.css.mf\" ./public/assets\n\n          Compile assets, providing some custom helpers to the transformation\n\n            $ asset-smasher --helpers helpers.js output\n\n### <a name=\"cli-helpers\"></a> Helpers\n\nThere is a built-in `asset_path` helper that can be used to get the \"real\" (i.e. with hashed file name) path of an asset.  E.g. `asset_path('css/myFile.css')` might return `'/assets/css/myFile-c89cba7b7df028e65cb01d86f4d27077.css`.\n\nSome transformers (e.g. the `.ejs` one) take in a set of local variables that they can use during transformation. You can pass in the path to a JavaScript module whose exports will be included in this set of variables.\n\nYou can use this, for example, to set configuration parameters in your JS files:\n\n**helper.js**\n\n    exports.serviceUrl = 'http://my.service/';\n\n**config.js.ejs**\n\n    //...\n    var serviceUrl = '<%= serviceUrl %>';\n    var cssLocation = '<%= asset_path('css/myFile.css') %>';\n    //...\n\n**Execution**\n\n    $ asset-smasher --helpers helper.js --only config.js.ejs,css/myFile.css .\n    $ cat config.js\n    var serviceUrl = 'http://my.service/';\n    var cssLocation = '/assets/css/myFile-c89cba7b7df028e65cb01d86f4d27077.css';\n\n\n### <a name=\"cli-plugins\"></a> Plugins\n\nIf there's a type of file you want to pre-process that is not natively supported by Asset Smasher, you can add it using a plugin file.\n\nFor an example of what the transformer classes look like, look in the `lib/compilation/transforms` directory\n\nIf a plugin module is passed (via `--plugins`), it will be `require()`d and then invoked, being passed in the asset smasher library (the module defined in `lib/asset-smasher.js`)\n\nTo register your transformer, just add another entry to the `transforms` object.\n\nE.g.\n\n**my_plugin.js**\n\n    module.exports = function(assetSmasher) {\n       // A stupid transformer that adds \"foo\" to the start and end of the contents\n       var FooTransform = function FooTransform(options) {\n         this.options = options || {};\n       };\n       FooTransform.prototype = {\n         extensions:function () {\n           return ['.foo'];\n         },\n         shouldTransform:function (file) {\n           return path.extname(file) === '.foo';\n         },\n         transformedFileName:function (file) {\n           return path.basename(file, '.foo');\n         },\n         transform:function (asset, cb) {\n           // Transform the file name\n           asset.logicalName = this.transformedFileName(asset.logicalName);\n           // Get the contents\n           var contents = asset.contents;\n           if (Buffer.isBuffer(contents)) {\n             contents = contents.toString('utf-8');\n           }\n           // Compile the contents\n           asset.contents = 'foo-' + contents + '-foo';\n           cb();\n         }\n       };\n\n       assetSmasher.transforms.Foo = FooTransform;\n    };\n\nIf you then invoke `asset-smasher` with `--plugins my_plugin.js` it will automatically transform `*.foo` files.\n\n## <a name=\"express-middleware\"></a> Using via Express Middleware\n\nAsset smasher exposes an `express` middleware that can:\n\n- Serve your assets un-merged/mangled in development mode.\n- Serve precompiled assets (with hashed file names) in production mode.\n\nThe middleware takes in the same arguments as the `Smasher` constructor, with a few extras:\n\n- `serve` - boolean (or object - see more below) indiacating whether the middleware should serve the asset files.  Usualy set this to `true` in development, `false` in production (e.g if you're using precompiled assets)\n    - An object can be passed in with the following properties to control the serving behavior. If `true` is passed in, the default values here will be used\n        - `individual` - Whether the individual (`true`) or merged files (`false`) should be served. Default `true`.\n- `assetMapLocation` - path to the `map.json` generated by the command-line `asset-smasher` util.  This allows the helper methods to determine what the hashed file names were\n\nThe middleware exposes two helpers to your views:\n\n- `js_asset(logicalPath)` - Render a `<script>` tag for the specified JS asset. When `serve` is true, this will \"explode\" manifests and write out a separate `<script>` for each required file.  This makes debugging much easier.\n- `css_asset(logicalPath)` - Render a `<link>` tag for the specified CSS asset.  Same thing happens when `serve` is true as with `js_asset`.\n- `raw_asset(logicalPath)` - Return the path to the asset.\n\nYou *must* include the middleware **before** the Express routing middleware. Otherwise the asset helper functions will not be available for your view to use.\n\n### Example\n\n    var assetSmasher = require('asset-smasher');\n\n**Middleware config (Dev)**\n\n    app.use(assetSmasher.middleware({\n      serve: true,\n      paths: [path.join(__dirname, 'assetDir1'), path.join(__dirname, 'assetDir2')],\n      prefix: '/assets',\n      outputTo: path.join(__dirname, 'tmp')\n    }));\n\n**Middleware config (Prod)**\n\n    app.use(assetSmasher.middleware({\n      serve: false,\n      prefix: '/assets',\n      assetMapLocation: path.join(__dirname, 'public/assets/map.json')\n    }));\n\n**Middleware config (Alternate Prod config not using precompilation, but instead compile on first access)**\n\nNote that if you use this configuration, you will **not** be able to use \"hashed\" filenames.\n\n    app.use(express.staticCache());\n    app.use(express.static(path.join(__dirname, 'public')));\n    app.use(assetSmasher.middleware({\n      serve: {\n        individual: false\n      },\n      paths: [path.join(__dirname, 'assetDir1'), path.join(__dirname, 'assetDir2')],\n      compress: true,\n      prefix: '/assets',\n      // This will make the files be served once by asset smasher\n      // and then by the express \"static\" middleware thereafter.\n      // You can then also use something like \"staticCache\" to cache the files if you're not\n      // using a reverse proxy cache on the public dir\n      outputTo: path.join(__dirname, 'public/assets')\n    }));\n\n**View (ejs here, but could be others)**\n\n    <!DOCTYPE html>\n    <html>\n    <head>\n      <title>Test</title>\n      <%- css_asset('application.css') %>\n      <%- js_asset('application.js') %>\n    </head>\n    <body>\n      This is a test\n    </body>\n    </html>\n\n## <a name=\"programmatic-interface\"></a> Using via Programmatic Interface\n\nYou can invoke Asset Smasher programmatically by `require`ing it.  You can also plug in additional transformers this way.\n\nThe `Smasher` object has the following methods:\n\n - `compileAssets(cb)` - Find and compile all the assets.\n - `compileSingleAsset(assetFilePath, cb)` - Compile a single asset (assetFilePath is the actual path to the file, not a logical path)\n - `findAssets(cb)` - Find, but don't compile the assets.  Good for determining dependency graph without compiling.\n - `getAssetByLogicalPath(logicalPath)` - Get information about an asset by its logical path.  Only call this after finding/compiling assets.\n - `getHashedFileMapping()` - When `hash` is true, this returns a mapping of logical path to \"hashed\" logical path.  This object is what the command-line tool outputs to `map.json`. Only call this after finding/compiling assets.\n - `getRequiredLogicalPathsFor(asset)` - Get the logical paths of the assets that should be merged into the specified asset (populated for `.mf` files). Only call this after finding/compiling assets.\n - `getProcessingOrderLogicalPaths()` - Get a list of the order in which assets should be processed in order to satisfy all dependencies. Only call this after finding/compiling assets.\n - `reset()` - Reset the asset metadata.\n\nThe `Asset` object returned by `getAssetByLogicalPath` has the following properties (and one method):\n\n - `logicalPath` - The logical path\n - `hashedPath` - If `hash` is true, the hashed filename path, otherwise the same as `logicalPath`\n - `assetFilePath` - The full path to the actual source asset\n - `compiled` - Whether the asset has been compiled\n - `compiledAssetFilePath` - The full path to the compiled asset file\n - `reset()` - Set the asset back to its before-compile state (clear out contents, set name back to pre-transform name)\n\n**Example**\n\n    var assetSmasher = require('asset-smasher');\n    var Smasher = assetSmasher.Smasher;\n\n    // Plug in a custom transformer\n    assetSmasher.transforms['MyAwesomeFormat'] = require('myAwesomeFormatTransformer');\n\n    var sm = new Smasher({\n      paths:['/path/one', '/path/two'],\n      only:['**/*.{jpg,gif,png}', 'application.js.mf', 'application.css.mf'],\n      prefix:'/assets',\n      compress:true,\n      hash:true,\n      hashVersion:'1.0',\n      gzip:true,\n      outputTo:__dirname + '/public/assets',\n      helpers:{\n       my: 'helper',\n       another: 'helper'\n      },\n      verbose:true,\n      noclean:true\n    });\n    sm.compileAssets(function(err) {\n      if(err) {\n        console.log('An error occurred', err);\n      } else {\n        console.log('Compilation done!');\n      }\n    });\n\n## <a name=\"transformer-notes\"></a> Transformer Notes\n\n### <a name=\"tn-less-styl\"></a> LESS/Stylus\n\n- Any `@include/@import` paths are *relative to the path that the file is in*.\n- Any `@include/@import`ed files will *not* be processed individually by Asset Smasher (i.e. you can't `@include` a LESS file that is preprocessed by ejs)\n\n### <a name=\"tn-ejs\"></a> ejs\n\n- Any registered helpers will be exposed as global variables to the `ejs` transform.\n- The built-in `asset_paths` helper can be used here.\n\n### <a name=\"tn-dust-hbs\"></a> dust and Handlebars\n\n- The name of the template will be the template's \"logical path\" (minus the asset path it is in), minus the `.js.dust` or `.js.hbs` file extension.\n    - E.g. `/my/templates/test.js.dust`'s template name will be `test` (assuming `/my/templates` is the asset path)\n","readmeFilename":"README.md","_id":"asset-smasher@0.2.11","dist":{"shasum":"32f5731b3239511e6c4b072f9eed10c228d83c6d","tarball":"https://registry.npmjs.org/asset-smasher/-/asset-smasher-0.2.11.tgz","integrity":"sha512-X9dfpeAFC4dyNxBjvu/rm0ypZH61V2BUqnGdJfFpM/DjtywUAc6CE5gdLiJ0xyjRFFRwQijNaXAdvYz42I7eQw==","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEYCIQDjOYs2clhBVWLAN8HP5FmUFPnENx2cAzoE5UG7vxnbCQIhANkNMFXUW0iB6xiiReTrxunDtKD5agRkrufda6Eq5xGF"}]},"_from":".","_npmVersion":"1.2.18","_npmUser":{"name":"jriecken","email":"jriecken@gmail.com"},"maintainers":[{"name":"jriecken","email":"jriecken@gmail.com"}]},"0.2.12":{"name":"asset-smasher","description":"Asset pre-processor, merger, and compressor.","version":"0.2.12","author":{"name":"Jim Riecken","email":"jriecken@gmail.com"},"keywords":["asset","compress","merge","preprocess"],"license":{"type":"MIT","url":"http://github.com/jriecken/asset-smasher/raw/master/LICENSE"},"repository":{"type":"git","url":"git://github.com/jriecken/asset-smasher.git"},"bugs":{"url":"http://github.com/jriecken/asset-smasher/issues"},"main":"./lib/asset-smasher.js","bin":{"asset-smasher":"./bin/asset-smasher"},"dependencies":{"async":"0.2.6","commander":"1.1.1","dependency-graph":"0.1.0","glob":"3.1.21","mkdirp":"0.3.5","minimatch":"0.2.11","rimraf":"2.1.4","send":"0.1.0","uglify-js":"2.2.5","underscore":"1.4.4","ycssmin":"1.0.1"},"optionalDependencies":{},"devDependencies":{},"engines":{"node":">= 0.6.0"},"readme":"# Asset Smasher\n\nAsset pre-processor, merger, and compressor for Node.js\n\n- [Structuring Your Assets](#structure-assets)\n    - [Manifest Files](#manifest-files)\n    - [Manifest Directories](#manifest-directories)\n- [Using via Command Line](#command-line)\n    - [Helpers](#cli-helpers)\n    - [Plugins](#cli-plugins)\n- [Using via Express Middleware](#express-middleware)\n- [Using via Programmatic Interface](#programmatic-interface)\n- [Transformer Notes](#transformer-notes)\n    - [LESS/Stylus](#tn-less-styl)\n    - [ejs](#tn-ejs)\n    - [dust and Handlebars](#tn-dust-hbs)\n\n## Overview\n\nAsset Smasher is a command-line tool, express middleware, and programmatic interface for:\n\n- Pre-processing and transforming files down to plain JavaScript and CSS.\n    - `.coffee` - Compile [CoffeeScript](http://coffeescript.org/) into JavaScript\n    - `.ejs` - Run a file through [EJS](https://github.com/visionmedia/ejs) (e.g. to populate configuration parameters into a JavaScript file)\n    - `.less` - Compile [Less](http://lesscss.org/) into CSS\n    - `.styl` - Compile [Stylus](http://learnboost.github.io/stylus/) into CSS\n    - `.hbs` - Precompile [Handlebars](http://handlebarsjs.com/) templates into JavaScript files that register them with `Handlebars.templates`.\n    - `.dust` - Precompile [Dust](http://linkedin.github.io/dustjs/) templates into JavaScript files that register them for use with `dust.render`.\n    - `.jsx` - Transform JSX files (for use with [React](http://facebook.github.io/react/)) into JavaScript files.\n    - Processors can be chained together.  E.g `test.js.hbs.ejs` (run Handlebars template through EJS, then compile it)\n    - Additional processors can be plugged in.\n- Merging files together using Manifest files (`.mf`) with dependency management directives similar to Sprockets.\n    - `require` - Require a single file\n    - `require_dir` - Require all the files in a specific directory\n    - `require_tree` - Require all the files in a specific directory (and subdirectories)\n- Compressing, gzipping, and generating hashed file names.\n    - Compress JavaScript files with `uglify-js`\n    - Compress CSS files with `ycssmin`\n    - Generate Gzipped versions of files\n    - Include a MD5 hash of the file's contents in the file name. `myAsset.js` -> `myAsset-c89cba7b7df028e65cb01d86f4d27077.js`\n        - `asset_path` helper that can be used to reference the hashed name.\n\nIt's released under the [MIT](http://en.wikipedia.org/wiki/MIT_License) license.\n\n## <a name=\"structure-assets\"></a> Structuring Your Assets\n\nAsset Smasher has the concept of \"asset paths\".  These are locations in which your asset files will be located, and from which any relative asset paths will be rooted to.\n\nThe simplest structure has one asset path.\n\nE.g.\n\n    Asset Paths\n    -----------\n     - app\n\n    File Structure\n    --------------\n    app/\n      js/\n      css/\n      images/\n\nA more complicated structure might be\n\n    Asset Paths\n    -----------\n     - app\n     - lib\n     - vendor\n\n    File Structure\n    --------------\n    app/\n      js/\n      css/\n      images/\n    lib/\n      js/\n      css/\n      images/\n    vendor/\n      js/\n      css/\n      images/\n\nBoth of these examples will result in a compiled structure of\n\n    js/\n    css/\n    images/\n\n### <a name=\"manifest-files\"></a> Manifest Files\n\nManifest (`.mf`) files are used to merge many assets into a single resulting file. The file should be named with the resulting file type before the `.mf` extension (e.g. `manifest.css.mf` or `manifest.js.mf`. *Manifest files can `require` other manifest files*\n\nOnly files that will be transformed down to a file of a manifest's \"type\" (e.g. `manifest.css.mf` => `.css`, `manifest.js.mf` => `.js`) will be included. This means that, for example, if you `require_dir` a directory in a JavaScript manifest that happens to contain both JavaScript and CSS, only the JavaScript files will be required.\n\nA simple manifest file might look like\n\n    # A comment here\n    require \"./one.js\"\n    require_dir \"./subdir1\"\n    #\n    # Another comment\n    require_tree \"./subdir2\"\n\n**Directives:**\n\n<table border=\"1\" cellpadding=\"5\" cellspacing=\"0\" width=\"100%\">\n <thead>\n  <tr><th width=\"15%\">Directive</th><th width=\"85%\">Description</th></tr>\n </thead>\n <tbody>\n  <tr>\n    <td><code>require \"[path]\"</code></td>\n    <td>\n      <strong>Include a single file</strong>\n      <ul>\n       <li>\n         If the path starts with <code>\"/\"</code>, <code>\"../\"</code>, or <code>\"./\"</code>, process and include the specified file.  The file <em>must</em> be\n         inside one of the configured asset paths.\n       </li>\n       <li>\n         If the path does not start with <code>\"/\"</code>, <code>\"../\"</code>, or <code>\"./\"</code>, the file will be searched for in all of the configured\n         asset paths.  E.g. if there are asset paths <code>one</code> and <code>two</code> defined, <code>require \"js/test.js\"</code>\n         will look for <code>one/js/test.js</code> and then <code>two/js/test.js</code> stopping when it finds a matching file.\n       </li>\n       <li>\n         The filename part of the path does not have to include the whole extension.  E.g <code>require \"test\"</code>\n         finds the first file that matches the name in the asset paths (for example <code>test.js.ejs</code>)\n       </li>\n       <li>\n         If the file does not exist/can't be resolved/isn't of the right type for the manifest, it will be ignored (will be logged in verbose mode).\n       </li>\n      </ul>\n    </td>\n  </tr>\n  <tr>\n    <td><code>require_dir \"[path]\"</code></td>\n    <td>\n      <strong>Include all the files in a directory</strong>\n      <ul>\n       <li>\n         The path must be absolute, or relative to the current directory.  E.g. you can do <code>require_dir \"../some/other/dir\"</code>\n         but not <code>require_dir \"somedir\"</code>\n       </li>\n       <li>\n         If using absolute paths, or <code>\"..\"</code> in your paths, the resulting directory needs to be inside one of the configured asset paths.\n       </li>\n       <li>\n         If the directory does not exist, it will be ignored (will be logged in verbose mode).\n       </li>\n      </ul>\n    </td>\n  </tr>\n  <tr>\n    <td><code>require_tree \"[path]\"</code></td>\n    <td>\n      <strong>Include the files in a directory recursively</strong>\n      <ul>\n        <li>The rules for <code>require_tree</code> are the same as the rules for <code>require_dir</code></li>\n      </ul>\n    </td>\n  </tr>\n </tbody>\n</table>\n\n### <a name=\"manifest-directories\"></a> Manifest Directories\n\nIf you create a directory, for example named `foo.js.mf` and put a bunch of javascript files in it (or any subdirectories under it), `asset-smasher` will (recursively) take all the files inside and merge them into `foo.js`.\n\nEssentially, this is a time-saver so that you don't have to create a manifest file that only contains a single `require_tree` directive.\n\n## <a name=\"command-line\"></a> Using via Command-Line\n\nUse `npm install -g asset-smasher` to install the `asset-smasher` command-line tool globally.\n\n      asset-smasher --help\n\n        Usage: asset-smasher [options] <output dir>\n\n        Options:\n\n          -h, --help               output usage information\n          -V, --version            output the version number\n          --compress               compress/minify the generated files\n          --hash                   generate versions of the files with md5 hashes in the name\n          --gzip                   generate gzipped versions of the compiled files\n          --hashVersion <version>  invalidate all assets without changing file contents [1.0]\n          --only <pattern,...>     only process the files matching these glob patterns (relative to any of the paths) [**/*]\n          --paths <path,...>       list of paths to look for assets [.]\n          --prefix <prefix>        prefix to append to logical paths when constructing urls. use if output dir is not served from the root of your web app []\n          --helpers <js_file>      a .js module of helper functions require()s to expose to transforms []\n          --plugins <js_file>      a .js plugin module []\n          --verbose                output more verbose information about what is going on to the console\n          --noclean                do not delete the output directory before generating files (by default it will be removed first)\n\n        If --only is not specified, *all* files in the --paths will be processed.\n        If --hash is specified, a map.json file will be generated that maps the unmangled file name to the hashed one.\n\n        Be careful that your shell doesn't expand glob patterns when passing them as arguments. To be safe, surround the argument with quotes.\n\n        Examples:\n\n          Compile all assets in the current directory to /home/me/compiledAssets\n\n            $ asset-smasher /home/me/compiledAssets\n\n          Something similar to what the Rails asset pipeline does by default\n\n            $ asset-smasher --compress --hash --gzip --prefix /assets \\\n                --paths ./js,./css,./images \\\n                --only \"**/*.jpg,**/*.gif,**/*.png,application.js.mf,application.css.mf\" ./public/assets\n\n          Compile assets, providing some custom helpers to the transformation\n\n            $ asset-smasher --helpers helpers.js output\n\n### <a name=\"cli-helpers\"></a> Helpers\n\nThere is a built-in `asset_path` helper that can be used to get the \"real\" (i.e. with hashed file name) path of an asset.  E.g. `asset_path('css/myFile.css')` might return `'/assets/css/myFile-c89cba7b7df028e65cb01d86f4d27077.css`.\n\nSome transformers (e.g. the `.ejs` one) take in a set of local variables that they can use during transformation. You can pass in the path to a JavaScript module whose exports will be included in this set of variables.\n\nYou can use this, for example, to set configuration parameters in your JS files:\n\n**helper.js**\n\n    exports.serviceUrl = 'http://my.service/';\n\n**config.js.ejs**\n\n    //...\n    var serviceUrl = '<%= serviceUrl %>';\n    var cssLocation = '<%= asset_path('css/myFile.css') %>';\n    //...\n\n**Execution**\n\n    $ asset-smasher --helpers helper.js --only config.js.ejs,css/myFile.css .\n    $ cat config.js\n    var serviceUrl = 'http://my.service/';\n    var cssLocation = '/assets/css/myFile-c89cba7b7df028e65cb01d86f4d27077.css';\n\n\n### <a name=\"cli-plugins\"></a> Plugins\n\nIf there's a type of file you want to pre-process that is not natively supported by Asset Smasher, you can add it using a plugin file.\n\nFor an example of what the transformer classes look like, look in the `lib/compilation/transforms` directory\n\nIf a plugin module is passed (via `--plugins`), it will be `require()`d and then invoked, being passed in the asset smasher library (the module defined in `lib/asset-smasher.js`)\n\nTo register your transformer, just add another entry to the `transforms` object.\n\nE.g.\n\n**my_plugin.js**\n\n    module.exports = function(assetSmasher) {\n       // A stupid transformer that adds \"foo\" to the start and end of the contents\n       var FooTransform = function FooTransform(options) {\n         this.options = options || {};\n       };\n       FooTransform.prototype = {\n         extensions:function () {\n           return ['.foo'];\n         },\n         shouldTransform:function (file) {\n           return path.extname(file) === '.foo';\n         },\n         transformedFileName:function (file) {\n           return path.basename(file, '.foo');\n         },\n         transform:function (asset, cb) {\n           // Transform the file name\n           asset.logicalName = this.transformedFileName(asset.logicalName);\n           // Get the contents\n           var contents = asset.contents;\n           if (Buffer.isBuffer(contents)) {\n             contents = contents.toString('utf-8');\n           }\n           // Compile the contents\n           asset.contents = 'foo-' + contents + '-foo';\n           cb();\n         }\n       };\n\n       assetSmasher.transforms.Foo = FooTransform;\n    };\n\nIf you then invoke `asset-smasher` with `--plugins my_plugin.js` it will automatically transform `*.foo` files.\n\n## <a name=\"express-middleware\"></a> Using via Express Middleware\n\nAsset smasher exposes an `express` middleware that can:\n\n- Serve your assets un-merged/mangled in development mode.\n- Serve precompiled assets (with hashed file names) in production mode.\n\nThe middleware takes in the same arguments as the `Smasher` constructor, with a few extras:\n\n- `serve` - boolean (or object - see more below) indiacating whether the middleware should serve the asset files.  Usualy set this to `true` in development, `false` in production (e.g if you're using precompiled assets)\n    - An object can be passed in with the following properties to control the serving behavior. If `true` is passed in, the default values here will be used\n        - `individual` - Whether the individual (`true`) or merged files (`false`) should be served. Default `true`.\n- `assetMapLocation` - path to the `map.json` generated by the command-line `asset-smasher` util.  This allows the helper methods to determine what the hashed file names were\n\nThe middleware exposes two helpers to your views:\n\n- `js_asset(logicalPath)` - Render a `<script>` tag for the specified JS asset. When `serve` is true, this will \"explode\" manifests and write out a separate `<script>` for each required file.  This makes debugging much easier.\n- `css_asset(logicalPath)` - Render a `<link>` tag for the specified CSS asset.  Same thing happens when `serve` is true as with `js_asset`.\n- `raw_asset(logicalPath)` - Return the path to the asset.\n\nYou *must* include the middleware **before** the Express routing middleware. Otherwise the asset helper functions will not be available for your view to use.\n\n### Example\n\n    var assetSmasher = require('asset-smasher');\n\n**Middleware config (Dev)**\n\n    app.use(assetSmasher.middleware({\n      serve: true,\n      paths: [path.join(__dirname, 'assetDir1'), path.join(__dirname, 'assetDir2')],\n      prefix: '/assets',\n      outputTo: path.join(__dirname, 'tmp')\n    }));\n\n**Middleware config (Prod)**\n\n    app.use(assetSmasher.middleware({\n      serve: false,\n      prefix: '/assets',\n      assetMapLocation: path.join(__dirname, 'public/assets/map.json')\n    }));\n\n**Middleware config (Alternate Prod config not using precompilation, but instead compile on first access)**\n\nNote that if you use this configuration, you will **not** be able to use \"hashed\" filenames.\n\n    app.use(express.staticCache());\n    app.use(express.static(path.join(__dirname, 'public')));\n    app.use(assetSmasher.middleware({\n      serve: {\n        individual: false\n      },\n      paths: [path.join(__dirname, 'assetDir1'), path.join(__dirname, 'assetDir2')],\n      compress: true,\n      prefix: '/assets',\n      // This will make the files be served once by asset smasher\n      // and then by the express \"static\" middleware thereafter.\n      // You can then also use something like \"staticCache\" to cache the files if you're not\n      // using a reverse proxy cache on the public dir\n      outputTo: path.join(__dirname, 'public/assets')\n    }));\n\n**View (ejs here, but could be others)**\n\n    <!DOCTYPE html>\n    <html>\n    <head>\n      <title>Test</title>\n      <%- css_asset('application.css') %>\n      <%- js_asset('application.js') %>\n    </head>\n    <body>\n      This is a test\n    </body>\n    </html>\n\n## <a name=\"programmatic-interface\"></a> Using via Programmatic Interface\n\nYou can invoke Asset Smasher programmatically by `require`ing it.  You can also plug in additional transformers this way.\n\nThe `Smasher` object has the following methods:\n\n - `compileAssets(cb)` - Find and compile all the assets.\n - `compileSingleAsset(assetFilePath, cb)` - Compile a single asset (assetFilePath is the actual path to the file, not a logical path)\n - `findAssets(cb)` - Find, but don't compile the assets.  Good for determining dependency graph without compiling.\n - `getAssetByLogicalPath(logicalPath)` - Get information about an asset by its logical path.  Only call this after finding/compiling assets.\n - `getHashedFileMapping()` - When `hash` is true, this returns a mapping of logical path to \"hashed\" logical path.  This object is what the command-line tool outputs to `map.json`. Only call this after finding/compiling assets.\n - `getRequiredLogicalPathsFor(asset)` - Get the logical paths of the assets that should be merged into the specified asset (populated for `.mf` files). Only call this after finding/compiling assets.\n - `getProcessingOrderLogicalPaths()` - Get a list of the order in which assets should be processed in order to satisfy all dependencies. Only call this after finding/compiling assets.\n - `reset()` - Reset the asset metadata.\n\nThe `Asset` object returned by `getAssetByLogicalPath` has the following properties (and one method):\n\n - `logicalPath` - The logical path\n - `hashedPath` - If `hash` is true, the hashed filename path, otherwise the same as `logicalPath`\n - `assetFilePath` - The full path to the actual source asset\n - `compiled` - Whether the asset has been compiled\n - `compiledAssetFilePath` - The full path to the compiled asset file\n - `reset()` - Set the asset back to its before-compile state (clear out contents, set name back to pre-transform name)\n\n**Example**\n\n    var assetSmasher = require('asset-smasher');\n    var Smasher = assetSmasher.Smasher;\n\n    // Plug in a custom transformer\n    assetSmasher.transforms['MyAwesomeFormat'] = require('myAwesomeFormatTransformer');\n\n    var sm = new Smasher({\n      paths:['/path/one', '/path/two'],\n      only:['**/*.{jpg,gif,png}', 'application.js.mf', 'application.css.mf'],\n      prefix:'/assets',\n      compress:true,\n      hash:true,\n      hashVersion:'1.0',\n      gzip:true,\n      outputTo:__dirname + '/public/assets',\n      helpers:{\n       my: 'helper',\n       another: 'helper'\n      },\n      verbose:true,\n      noclean:true\n    });\n    sm.compileAssets(function(err) {\n      if(err) {\n        console.log('An error occurred', err);\n      } else {\n        console.log('Compilation done!');\n      }\n    });\n\n## <a name=\"transformer-notes\"></a> Transformer Notes\n\nTo use a transformer you must install the associated node module.\n - `.coffee` - `npm install coffee-script`\n - `.dust` - `npm install dustjs-linkedin`\n - `.ejs` - `npm install ejs`\n - `.hbs` - `npm install handlebars`\n - `.jsx` - `npm install react-tools`\n - `.less` - `npm install less`\n - `.styl` - `npm install stylus`\n\n### <a name=\"tn-less-styl\"></a> LESS/Stylus\n\n- Any `@include/@import` paths are *relative to the path that the file is in*.\n- Any `@include/@import`ed files will *not* be processed individually by Asset Smasher (i.e. you can't `@include` a LESS file that is preprocessed by ejs)\n\n### <a name=\"tn-ejs\"></a> ejs\n\n- Any registered helpers will be exposed as global variables to the `ejs` transform.\n- The built-in `asset_paths` helper can be used here.\n\n### <a name=\"tn-dust-hbs\"></a> dust and Handlebars\n\n- The name of the template will be the template's \"logical path\" (minus the asset path it is in), minus the `.js.dust` or `.js.hbs` file extension.\n    - E.g. `/my/templates/test.js.dust`'s template name will be `test` (assuming `/my/templates` is the asset path)\n","readmeFilename":"README.md","_id":"asset-smasher@0.2.12","dist":{"shasum":"88db7479fa7bc0dfa41b85930536b50217247f53","tarball":"https://registry.npmjs.org/asset-smasher/-/asset-smasher-0.2.12.tgz","integrity":"sha512-QX7p/WpPWuHf1Ml7x95I3eFkM/wUNYG9tibsrayhIR7cgAUU2GlVd11Iu7wLRja3ifHKDqj9V3rXUW7Ww5WISA==","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIH3ZM8U+Ut/5f7AaRT70urvI6/2cICDQPjrd1Fv40+VaAiEAmkhVgvlN9r3jLg/Qq0AhDloQyx4cjGeH2JDowCpdNVw="}]},"_from":".","_npmVersion":"1.2.23","_npmUser":{"name":"jriecken","email":"jriecken@gmail.com"},"maintainers":[{"name":"jriecken","email":"jriecken@gmail.com"}]},"0.3.0":{"name":"asset-smasher","description":"Asset pre-processor, merger, and compressor.","version":"0.3.0","author":{"name":"Jim Riecken","email":"jriecken@gmail.com"},"keywords":["asset","compress","merge","preprocess"],"license":{"type":"MIT","url":"http://github.com/jriecken/asset-smasher/raw/master/LICENSE"},"repository":{"type":"git","url":"git://github.com/jriecken/asset-smasher.git"},"bugs":{"url":"http://github.com/jriecken/asset-smasher/issues"},"main":"./lib/asset-smasher.js","bin":{"asset-smasher":"./bin/asset-smasher"},"dependencies":{"async":"0.2.6","commander":"1.1.1","dependency-graph":"0.1.0","glob":"3.1.21","mkdirp":"0.3.5","minimatch":"0.2.11","rimraf":"2.1.4","send":"0.1.0","uglify-js":"2.2.5","underscore":"1.4.4","ycssmin":"1.0.1"},"optionalDependencies":{},"devDependencies":{},"engines":{"node":">= 0.6.0"},"readme":"# Asset Smasher\n\nAsset pre-processor, merger, and compressor for Node.js\n\n- [Structuring Your Assets](#structure-assets)\n    - [Manifest Files](#manifest-files)\n    - [Manifest Directories](#manifest-directories)\n- [Using via Command Line](#command-line)\n    - [Helpers](#cli-helpers)\n    - [Plugins](#cli-plugins)\n- [Using via Express Middleware](#express-middleware)\n- [Using via Programmatic Interface](#programmatic-interface)\n- [Transformer Notes](#transformer-notes)\n    - [AMD Support](#tn-amd)\n    - [LESS/Stylus](#tn-less-styl)\n    - [ejs](#tn-ejs)\n    - [dust and Handlebars](#tn-dust-hbs)\n\n## Overview\n\nAsset Smasher is a command-line tool, express middleware, and programmatic interface for:\n\n- Pre-processing and transforming files down to plain JavaScript and CSS.\n    - `.coffee` - Compile [CoffeeScript](http://coffeescript.org/) into JavaScript\n    - `.ejs` - Run a file through [EJS](https://github.com/visionmedia/ejs) (e.g. to populate configuration parameters into a JavaScript file)\n    - `.less` - Compile [Less](http://lesscss.org/) into CSS\n    - `.styl` - Compile [Stylus](http://learnboost.github.io/stylus/) into CSS\n    - `.hbs` - Precompile [Handlebars](http://handlebarsjs.com/) templates into JavaScript files that register them with `Handlebars.templates`.\n    - `.dust` - Precompile [Dust](http://linkedin.github.io/dustjs/) templates into JavaScript files that register them for use with `dust.render`.\n    - `.jsx` - Transform JSX files (for use with [React](http://facebook.github.io/react/)) into JavaScript files.\n    - Can wrap CommonJS-style JavaScript files with [AMD](https://github.com/amdjs/amdjs-api/wiki/AMD) `define` calls.\n    - Processors can be chained together.  E.g `test.js.hbs.ejs` (run Handlebars template through EJS, then compile it)\n    - Additional processors can be plugged in.\n- Merging files together using Manifest files (`.mf`) with dependency management directives similar to Sprockets.\n    - `require` - Require a single file\n    - `require_dir` - Require all the files in a specific directory\n    - `require_tree` - Require all the files in a specific directory (and subdirectories)\n- Compressing, gzipping, and generating hashed file names.\n    - Compress JavaScript files with `uglify-js`\n    - Compress CSS files with `ycssmin`\n    - Generate Gzipped versions of files\n    - Include a MD5 hash of the file's contents in the file name. `myAsset.js` -> `myAsset-c89cba7b7df028e65cb01d86f4d27077.js`\n        - `asset_path` helper that can be used to reference the hashed name.\n\nIt's released under the [MIT](http://en.wikipedia.org/wiki/MIT_License) license.\n\n## <a name=\"structure-assets\"></a> Structuring Your Assets\n\nAsset Smasher has the concept of \"asset paths\".  These are locations in which your asset files will be located, and from which any relative asset paths will be rooted to.\n\nThe simplest structure has one asset path.\n\nE.g.\n\n    Asset Paths\n    -----------\n     - app\n\n    File Structure\n    --------------\n    app/\n      js/\n      css/\n      images/\n\nA more complicated structure might be\n\n    Asset Paths\n    -----------\n     - app\n     - lib\n     - vendor\n\n    File Structure\n    --------------\n    app/\n      js/\n      css/\n      images/\n    lib/\n      js/\n      css/\n      images/\n    vendor/\n      js/\n      css/\n      images/\n\nBoth of these examples will result in a compiled structure of\n\n    js/\n    css/\n    images/\n\n### <a name=\"manifest-files\"></a> Manifest Files\n\nManifest (`.mf`) files are used to merge many assets into a single resulting file. The file should be named with the resulting file type before the `.mf` extension (e.g. `manifest.css.mf` or `manifest.js.mf`. *Manifest files can `require` other manifest files*\n\nOnly files that will be transformed down to a file of a manifest's \"type\" (e.g. `manifest.css.mf` => `.css`, `manifest.js.mf` => `.js`) will be included. This means that, for example, if you `require_dir` a directory in a JavaScript manifest that happens to contain both JavaScript and CSS, only the JavaScript files will be required.\n\nA simple manifest file might look like\n\n    # A comment here\n    require \"./one.js\"\n    require_dir \"./subdir1\"\n    #\n    # Another comment\n    require_tree \"./subdir2\"\n\n**Directives:**\n\n<table border=\"1\" cellpadding=\"5\" cellspacing=\"0\" width=\"100%\">\n <thead>\n  <tr><th width=\"15%\">Directive</th><th width=\"85%\">Description</th></tr>\n </thead>\n <tbody>\n  <tr>\n    <td><code>require \"[path]\"</code></td>\n    <td>\n      <strong>Include a single file</strong>\n      <ul>\n       <li>\n         If the path starts with <code>\"/\"</code>, <code>\"../\"</code>, or <code>\"./\"</code>, process and include the specified file.  The file <em>must</em> be\n         inside one of the configured asset paths.\n       </li>\n       <li>\n         If the path does not start with <code>\"/\"</code>, <code>\"../\"</code>, or <code>\"./\"</code>, the file will be searched for in all of the configured\n         asset paths.  E.g. if there are asset paths <code>one</code> and <code>two</code> defined, <code>require \"js/test.js\"</code>\n         will look for <code>one/js/test.js</code> and then <code>two/js/test.js</code> stopping when it finds a matching file.\n       </li>\n       <li>\n         The filename part of the path does not have to include the whole extension.  E.g <code>require \"test\"</code>\n         finds the first file that matches the name in the asset paths (for example <code>test.js.ejs</code>)\n       </li>\n       <li>\n         If the file does not exist/can't be resolved/isn't of the right type for the manifest, it will be ignored (will be logged in verbose mode).\n       </li>\n      </ul>\n    </td>\n  </tr>\n  <tr>\n    <td><code>require_dir \"[path]\"</code></td>\n    <td>\n      <strong>Include all the files in a directory</strong>\n      <ul>\n       <li>\n         The path must be absolute, or relative to the current directory.  E.g. you can do <code>require_dir \"../some/other/dir\"</code>\n         but not <code>require_dir \"somedir\"</code>\n       </li>\n       <li>\n         If using absolute paths, or <code>\"..\"</code> in your paths, the resulting directory needs to be inside one of the configured asset paths.\n       </li>\n       <li>\n         If the directory does not exist, it will be ignored (will be logged in verbose mode).\n       </li>\n      </ul>\n    </td>\n  </tr>\n  <tr>\n    <td><code>require_tree \"[path]\"</code></td>\n    <td>\n      <strong>Include the files in a directory recursively</strong>\n      <ul>\n        <li>The rules for <code>require_tree</code> are the same as the rules for <code>require_dir</code></li>\n      </ul>\n    </td>\n  </tr>\n </tbody>\n</table>\n\n### <a name=\"manifest-directories\"></a> Manifest Directories\n\nIf you create a directory, for example named `foo.js.mf` and put a bunch of javascript files in it (or any subdirectories under it), `asset-smasher` will (recursively) take all the files inside and merge them into `foo.js`.\n\nEssentially, this is a time-saver so that you don't have to create a manifest file that only contains a single `require_tree` directive.\n\n## <a name=\"command-line\"></a> Using via Command-Line\n\nUse `npm install -g asset-smasher` to install the `asset-smasher` command-line tool globally.\n\n      asset-smasher --help\n\n        Usage: asset-smasher [options] <output dir>\n\n        Options:\n\n          -h, --help               output usage information\n          -V, --version            output the version number\n          --compress               compress/minify the generated files\n          --hash                   generate versions of the files with md5 hashes in the name\n          --gzip                   generate gzipped versions of the compiled files\n          --hashVersion <version>  invalidate all assets without changing file contents [1.0]\n          --only <pattern,...>     only process the files matching these glob patterns (relative to any of the paths) [**/*]\n          --paths <path,...>       list of paths to look for assets [.]\n          --prefix <prefix>        prefix to append to logical paths when constructing urls. use if output dir is not served from the root of your web app []\n          --helpers <js_file>      a .js module of helper functions require()s to expose to transforms []\n          --plugins <js_file>      a .js plugin module []\n          --verbose                output more verbose information about what is going on to the console\n          --noclean                do not delete the output directory before generating files (by default it will be removed first)\n\n        If --only is not specified, *all* files in the --paths will be processed.\n        If --hash is specified, a map.json file will be generated that maps the unmangled file name to the hashed one.\n\n        Be careful that your shell doesn't expand glob patterns when passing them as arguments. To be safe, surround the argument with quotes.\n\n        Examples:\n\n          Compile all assets in the current directory to /home/me/compiledAssets\n\n            $ asset-smasher /home/me/compiledAssets\n\n          Something similar to what the Rails asset pipeline does by default\n\n            $ asset-smasher --compress --hash --gzip --prefix /assets \\\n                --paths ./js,./css,./images \\\n                --only \"**/*.jpg,**/*.gif,**/*.png,application.js.mf,application.css.mf\" ./public/assets\n\n          Compile assets, providing some custom helpers to the transformation\n\n            $ asset-smasher --helpers helpers.js output\n\n### <a name=\"cli-helpers\"></a> Helpers\n\nThere is a built-in `asset_path` helper that can be used to get the \"real\" (i.e. with hashed file name) path of an asset.  E.g. `asset_path('css/myFile.css')` might return `'/assets/css/myFile-c89cba7b7df028e65cb01d86f4d27077.css`.\n\nSome transformers (e.g. the `.ejs` one) take in a set of local variables that they can use during transformation. You can pass in the path to a JavaScript module whose exports will be included in this set of variables.\n\nYou can use this, for example, to set configuration parameters in your JS files:\n\n**helper.js**\n\n    exports.serviceUrl = 'http://my.service/';\n\n**config.js.ejs**\n\n    //...\n    var serviceUrl = '<%= serviceUrl %>';\n    var cssLocation = '<%= asset_path('css/myFile.css') %>';\n    //...\n\n**Execution**\n\n    $ asset-smasher --helpers helper.js --only config.js.ejs,css/myFile.css .\n    $ cat config.js\n    var serviceUrl = 'http://my.service/';\n    var cssLocation = '/assets/css/myFile-c89cba7b7df028e65cb01d86f4d27077.css';\n\n\n### <a name=\"cli-plugins\"></a> Plugins\n\nIf there's a type of file you want to pre-process that is not natively supported by Asset Smasher, you can add it using a plugin file.\n\nFor an example of what the transformer classes look like, look in the `lib/compilation/transforms` directory\n\nIf a plugin module is passed (via `--plugins`), it will be `require()`d and then invoked, being passed in the asset smasher library (the module defined in `lib/asset-smasher.js`)\n\nTo register your transformer, just add another entry to the `transforms` object.\n\nE.g.\n\n**my_plugin.js**\n\n    module.exports = function(assetSmasher) {\n       // A stupid transformer that adds \"foo\" to the start and end of the contents\n       var FooTransform = function FooTransform(options) {\n         this.options = options || {};\n       };\n       FooTransform.prototype = {\n         extensions:function () {\n           return ['.foo'];\n         },\n         shouldTransform:function (file) {\n           return path.extname(file) === '.foo';\n         },\n         transformedFileName:function (file) {\n           return path.basename(file, '.foo');\n         },\n         transform:function (asset, cb) {\n           // Transform the file name\n           asset.logicalName = this.transformedFileName(asset.logicalName);\n           // Get the contents\n           var contents = asset.contents;\n           if (Buffer.isBuffer(contents)) {\n             contents = contents.toString('utf-8');\n           }\n           // Compile the contents\n           asset.contents = 'foo-' + contents + '-foo';\n           cb();\n         }\n       };\n\n       assetSmasher.transforms.Foo = FooTransform;\n    };\n\nIf you then invoke `asset-smasher` with `--plugins my_plugin.js` it will automatically transform `*.foo` files.\n\n## <a name=\"express-middleware\"></a> Using via Express Middleware\n\nAsset smasher exposes an `express` middleware that can:\n\n- Serve your assets un-merged/mangled in development mode.\n- Serve precompiled assets (with hashed file names) in production mode.\n\nThe middleware takes in the same arguments as the `Smasher` constructor, with a few extras:\n\n- `serve` - boolean (or object - see more below) indiacating whether the middleware should serve the asset files.  Usualy set this to `true` in development, `false` in production (e.g if you're using precompiled assets)\n    - An object can be passed in with the following properties to control the serving behavior. If `true` is passed in, the default values here will be used\n        - `individual` - Whether the individual (`true`) or merged files (`false`) should be served. Default `true`.\n- `assetMapLocation` - path to the `map.json` generated by the command-line `asset-smasher` util.  This allows the helper methods to determine what the hashed file names were\n\nThe middleware exposes two helpers to your views:\n\n- `js_asset(logicalPath)` - Render a `<script>` tag for the specified JS asset. When `serve` is true, this will \"explode\" manifests and write out a separate `<script>` for each required file.  This makes debugging much easier.\n- `css_asset(logicalPath)` - Render a `<link>` tag for the specified CSS asset.  Same thing happens when `serve` is true as with `js_asset`.\n- `raw_asset(logicalPath)` - Return the path to the asset.\n\nYou *must* include the middleware **before** the Express routing middleware. Otherwise the asset helper functions will not be available for your view to use.\n\n### Example\n\n    var assetSmasher = require('asset-smasher');\n\n**Middleware config (Dev)**\n\n    app.use(assetSmasher.middleware({\n      serve: true,\n      paths: [path.join(__dirname, 'assetDir1'), path.join(__dirname, 'assetDir2')],\n      prefix: '/assets',\n      outputTo: path.join(__dirname, 'tmp')\n    }));\n\n**Middleware config (Prod)**\n\n    app.use(assetSmasher.middleware({\n      serve: false,\n      prefix: '/assets',\n      assetMapLocation: path.join(__dirname, 'public/assets/map.json')\n    }));\n\n**Middleware config (Alternate Prod config not using precompilation, but instead compile on first access)**\n\nNote that if you use this configuration, you will **not** be able to use \"hashed\" filenames.\n\n    app.use(express.staticCache());\n    app.use(express.static(path.join(__dirname, 'public')));\n    app.use(assetSmasher.middleware({\n      serve: {\n        individual: false\n      },\n      paths: [path.join(__dirname, 'assetDir1'), path.join(__dirname, 'assetDir2')],\n      compress: true,\n      prefix: '/assets',\n      // This will make the files be served once by asset smasher\n      // and then by the express \"static\" middleware thereafter.\n      // You can then also use something like \"staticCache\" to cache the files if you're not\n      // using a reverse proxy cache on the public dir\n      outputTo: path.join(__dirname, 'public/assets')\n    }));\n\n**View (ejs here, but could be others)**\n\n    <!DOCTYPE html>\n    <html>\n    <head>\n      <title>Test</title>\n      <%- css_asset('application.css') %>\n      <%- js_asset('application.js') %>\n    </head>\n    <body>\n      This is a test\n    </body>\n    </html>\n\n## <a name=\"programmatic-interface\"></a> Using via Programmatic Interface\n\nYou can invoke Asset Smasher programmatically by `require`ing it.  You can also plug in additional transformers this way.\n\nThe `Smasher` object has the following methods:\n\n - `compileAssets(cb)` - Find and compile all the assets.\n - `compileSingleAsset(assetFilePath, cb)` - Compile a single asset (assetFilePath is the actual path to the file, not a logical path)\n - `findAssets(cb)` - Find, but don't compile the assets.  Good for determining dependency graph without compiling.\n - `getAssetByLogicalPath(logicalPath)` - Get information about an asset by its logical path.  Only call this after finding/compiling assets.\n - `getHashedFileMapping()` - When `hash` is true, this returns a mapping of logical path to \"hashed\" logical path.  This object is what the command-line tool outputs to `map.json`. Only call this after finding/compiling assets.\n - `getRequiredLogicalPathsFor(asset)` - Get the logical paths of the assets that should be merged into the specified asset (populated for `.mf` files). Only call this after finding/compiling assets.\n - `getProcessingOrderLogicalPaths()` - Get a list of the order in which assets should be processed in order to satisfy all dependencies. Only call this after finding/compiling assets.\n - `reset()` - Reset the asset metadata.\n\nThe `Asset` object returned by `getAssetByLogicalPath` has the following properties (and one method):\n\n - `logicalPath` - The logical path\n - `hashedPath` - If `hash` is true, the hashed filename path, otherwise the same as `logicalPath`\n - `assetFilePath` - The full path to the actual source asset\n - `compiled` - Whether the asset has been compiled\n - `compiledAssetFilePath` - The full path to the compiled asset file\n - `reset()` - Set the asset back to its before-compile state (clear out contents, set name back to pre-transform name)\n\n**Example**\n\n    var assetSmasher = require('asset-smasher');\n    var Smasher = assetSmasher.Smasher;\n\n    // Plug in a custom transformer\n    assetSmasher.transforms['MyAwesomeFormat'] = require('myAwesomeFormatTransformer');\n\n    var sm = new Smasher({\n      paths:['/path/one', '/path/two'],\n      only:['**/*.{jpg,gif,png}', 'application.js.mf', 'application.css.mf'],\n      prefix:'/assets',\n      compress:true,\n      hash:true,\n      hashVersion:'1.0',\n      gzip:true,\n      outputTo:__dirname + '/public/assets',\n      helpers:{\n       my: 'helper',\n       another: 'helper'\n      },\n      verbose:true,\n      noclean:true\n    });\n    sm.compileAssets(function(err) {\n      if(err) {\n        console.log('An error occurred', err);\n      } else {\n        console.log('Compilation done!');\n      }\n    });\n\n## <a name=\"transformer-notes\"></a> Transformer Notes\n\nTo use a transformer you must install the associated node module.\n - `.coffee` - `npm install coffee-script`\n - `.dust` - `npm install dustjs-linkedin`\n - `.ejs` - `npm install ejs`\n - `.hbs` - `npm install handlebars`\n - `.jsx` - `npm install react-tools`\n - `.less` - `npm install less`\n - `.styl` - `npm install stylus`\n\n### <a name=\"tn-amd\"></a> AMD Support\n\nAsset-smasher can wrap JavaScript files that follow the [CommonJS](http://wiki.commonjs.org/wiki/Modules) module format with [Asynchronous Module Definition](https://github.com/amdjs/amdjs-api/wiki/AMD) `define` calls.\n\nTo enable the wrapping of a JavaScript file, put the following at the top of it:\n\n    /** @amd */\n\nThis will cause asset smasher to:\n - Parse the contents of the file for any `require` calls\n - Wrap the contents of the file with a `define` call where the module id is the logical path of the file (minus `.js`) and the dependencies are anything that was `require`d. `require`, `exports`, and `module` are always dependencies.\n\nExample (say the file is in `scripts/foo.js`)\n\n    /** @amd */\n    var x = require('x');\n    var y = require('../y');\n    \n    exports.foo = function (bar) {\n      return x(bar) + y(bar);\n    };\n\nThis will be transformed into:\n\n    define('scripts/foo',\n           ['require', 'exports', 'module', 'x', '../y'],\n           function (require, exports, module, x, y) {\n      var x = require('x');\n      var y = require('../y');\n      \n      exports.foo = function (bar) {\n        return x(bar) + y(bar);\n      };\n    });\n\nYou can then use an AMD loader (like [require.js](http://requirejs.org/)) to load the modules.\n\n### <a name=\"tn-less-styl\"></a> LESS/Stylus\n\n- Any `@include/@import` paths are *relative to the path that the file is in*.\n- Any `@include/@import`ed files will *not* be processed individually by Asset Smasher (i.e. you can't `@include` a LESS file that is preprocessed by ejs)\n\n### <a name=\"tn-ejs\"></a> ejs\n\n- Any registered helpers will be exposed as global variables to the `ejs` transform.\n- The built-in `asset_paths` helper can be used here.\n\n### <a name=\"tn-dust-hbs\"></a> dust and Handlebars\n\n- The name of the template will be the template's \"logical path\" (minus the asset path it is in), minus the `.js.dust` or `.js.hbs` file extension.\n    - E.g. `/my/templates/test.js.dust`'s template name will be `test` (assuming `/my/templates` is the asset path)\n","readmeFilename":"README.md","_id":"asset-smasher@0.3.0","dist":{"shasum":"1b05716496c1463104b4e2a451d67efe18e8d031","tarball":"https://registry.npmjs.org/asset-smasher/-/asset-smasher-0.3.0.tgz","integrity":"sha512-KgN9SJTbfmTDCqp5U7SCNrugYwjdbgOD8zM81c7yhHW1oK8Yf2EYd6mTFpk9yCalihSFiW012o4aeCGX4FYJkA==","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIQDGcOEqB/eWYdOdfmi6i5fa2+z2noDRnSBDibliszgtpQIgMwOqMipszyXu7anowISUFauvHnj5P9brp5qFT1S+Gg0="}]},"_from":".","_npmVersion":"1.2.23","_npmUser":{"name":"jriecken","email":"jriecken@gmail.com"},"maintainers":[{"name":"jriecken","email":"jriecken@gmail.com"}]},"0.3.1":{"name":"asset-smasher","description":"Asset pre-processor, merger, and compressor.","version":"0.3.1","author":{"name":"Jim Riecken","email":"jriecken@gmail.com"},"keywords":["asset","compress","merge","preprocess"],"license":{"type":"MIT","url":"http://github.com/jriecken/asset-smasher/raw/master/LICENSE"},"repository":{"type":"git","url":"git://github.com/jriecken/asset-smasher.git"},"bugs":{"url":"http://github.com/jriecken/asset-smasher/issues"},"main":"./lib/asset-smasher.js","bin":{"asset-smasher":"./bin/asset-smasher"},"dependencies":{"async":"0.2.6","commander":"1.1.1","dependency-graph":"0.1.0","glob":"3.1.21","mkdirp":"0.3.5","minimatch":"0.2.11","rimraf":"2.1.4","send":"0.1.0","uglify-js":"2.2.5","underscore":"1.4.4","ycssmin":"1.0.1"},"optionalDependencies":{},"devDependencies":{},"engines":{"node":">= 0.6.0"},"readme":"# Asset Smasher\n\nAsset pre-processor, merger, and compressor for Node.js\n\n- [Structuring Your Assets](#structure-assets)\n    - [Manifest Files](#manifest-files)\n    - [Manifest Directories](#manifest-directories)\n- [Using via Command Line](#command-line)\n    - [Helpers](#cli-helpers)\n    - [Plugins](#cli-plugins)\n- [Using via Express Middleware](#express-middleware)\n- [Using via Programmatic Interface](#programmatic-interface)\n- [Transformer Notes](#transformer-notes)\n    - [AMD Support](#tn-amd)\n    - [LESS/Stylus](#tn-less-styl)\n    - [ejs](#tn-ejs)\n    - [dust and Handlebars](#tn-dust-hbs)\n\n## Overview\n\nAsset Smasher is a command-line tool, express middleware, and programmatic interface for:\n\n- Pre-processing and transforming files down to plain JavaScript and CSS.\n    - `.coffee` - Compile [CoffeeScript](http://coffeescript.org/) into JavaScript\n    - `.ejs` - Run a file through [EJS](https://github.com/visionmedia/ejs) (e.g. to populate configuration parameters into a JavaScript file)\n    - `.less` - Compile [Less](http://lesscss.org/) into CSS\n    - `.styl` - Compile [Stylus](http://learnboost.github.io/stylus/) into CSS\n    - `.hbs` - Precompile [Handlebars](http://handlebarsjs.com/) templates into JavaScript files that register them with `Handlebars.templates`.\n    - `.dust` - Precompile [Dust](http://linkedin.github.io/dustjs/) templates into JavaScript files that register them for use with `dust.render`.\n    - `.jsx` - Transform JSX files (for use with [React](http://facebook.github.io/react/)) into JavaScript files.\n    - Can wrap CommonJS-style JavaScript files with [AMD](https://github.com/amdjs/amdjs-api/wiki/AMD) `define` calls.\n    - Processors can be chained together.  E.g `test.js.hbs.ejs` (run Handlebars template through EJS, then compile it)\n    - Additional processors can be plugged in.\n- Merging files together using Manifest files (`.mf`) with dependency management directives similar to Sprockets.\n    - `require` - Require a single file\n    - `require_dir` - Require all the files in a specific directory\n    - `require_tree` - Require all the files in a specific directory (and subdirectories)\n- Compressing, gzipping, and generating hashed file names.\n    - Compress JavaScript files with `uglify-js`\n    - Compress CSS files with `ycssmin`\n    - Generate Gzipped versions of files\n    - Include a MD5 hash of the file's contents in the file name. `myAsset.js` -> `myAsset-c89cba7b7df028e65cb01d86f4d27077.js`\n        - `asset_path` helper that can be used to reference the hashed name.\n\nIt's released under the [MIT](http://en.wikipedia.org/wiki/MIT_License) license.\n\n## <a name=\"structure-assets\"></a> Structuring Your Assets\n\nAsset Smasher has the concept of \"asset paths\".  These are locations in which your asset files will be located, and from which any relative asset paths will be rooted to.\n\nThe simplest structure has one asset path.\n\nE.g.\n\n    Asset Paths\n    -----------\n     - app\n\n    File Structure\n    --------------\n    app/\n      js/\n      css/\n      images/\n\nA more complicated structure might be\n\n    Asset Paths\n    -----------\n     - app\n     - lib\n     - vendor\n\n    File Structure\n    --------------\n    app/\n      js/\n      css/\n      images/\n    lib/\n      js/\n      css/\n      images/\n    vendor/\n      js/\n      css/\n      images/\n\nBoth of these examples will result in a compiled structure of\n\n    js/\n    css/\n    images/\n\n### <a name=\"manifest-files\"></a> Manifest Files\n\nManifest (`.mf`) files are used to merge many assets into a single resulting file. The file should be named with the resulting file type before the `.mf` extension (e.g. `manifest.css.mf` or `manifest.js.mf`. *Manifest files can `require` other manifest files*\n\nOnly files that will be transformed down to a file of a manifest's \"type\" (e.g. `manifest.css.mf` => `.css`, `manifest.js.mf` => `.js`) will be included. This means that, for example, if you `require_dir` a directory in a JavaScript manifest that happens to contain both JavaScript and CSS, only the JavaScript files will be required.\n\nA simple manifest file might look like\n\n    # A comment here\n    require \"./one.js\"\n    require_dir \"./subdir1\"\n    #\n    # Another comment\n    require_tree \"./subdir2\"\n\n**Directives:**\n\n<table border=\"1\" cellpadding=\"5\" cellspacing=\"0\" width=\"100%\">\n <thead>\n  <tr><th width=\"15%\">Directive</th><th width=\"85%\">Description</th></tr>\n </thead>\n <tbody>\n  <tr>\n    <td><code>require \"[path]\"</code></td>\n    <td>\n      <strong>Include a single file</strong>\n      <ul>\n       <li>\n         If the path starts with <code>\"/\"</code>, <code>\"../\"</code>, or <code>\"./\"</code>, process and include the specified file.  The file <em>must</em> be\n         inside one of the configured asset paths.\n       </li>\n       <li>\n         If the path does not start with <code>\"/\"</code>, <code>\"../\"</code>, or <code>\"./\"</code>, the file will be searched for in all of the configured\n         asset paths.  E.g. if there are asset paths <code>one</code> and <code>two</code> defined, <code>require \"js/test.js\"</code>\n         will look for <code>one/js/test.js</code> and then <code>two/js/test.js</code> stopping when it finds a matching file.\n       </li>\n       <li>\n         The filename part of the path does not have to include the whole extension.  E.g <code>require \"test\"</code>\n         finds the first file that matches the name in the asset paths (for example <code>test.js.ejs</code>)\n       </li>\n       <li>\n         If the file does not exist/can't be resolved/isn't of the right type for the manifest, it will be ignored (will be logged in verbose mode).\n       </li>\n      </ul>\n    </td>\n  </tr>\n  <tr>\n    <td><code>require_dir \"[path]\"</code></td>\n    <td>\n      <strong>Include all the files in a directory</strong>\n      <ul>\n       <li>\n         The path must be absolute, or relative to the current directory.  E.g. you can do <code>require_dir \"../some/other/dir\"</code>\n         but not <code>require_dir \"somedir\"</code>\n       </li>\n       <li>\n         If using absolute paths, or <code>\"..\"</code> in your paths, the resulting directory needs to be inside one of the configured asset paths.\n       </li>\n       <li>\n         If the directory does not exist, it will be ignored (will be logged in verbose mode).\n       </li>\n      </ul>\n    </td>\n  </tr>\n  <tr>\n    <td><code>require_tree \"[path]\"</code></td>\n    <td>\n      <strong>Include the files in a directory recursively</strong>\n      <ul>\n        <li>The rules for <code>require_tree</code> are the same as the rules for <code>require_dir</code></li>\n      </ul>\n    </td>\n  </tr>\n </tbody>\n</table>\n\n### <a name=\"manifest-directories\"></a> Manifest Directories\n\nIf you create a directory, for example named `foo.js.mf` and put a bunch of javascript files in it (or any subdirectories under it), `asset-smasher` will (recursively) take all the files inside and merge them into `foo.js`.\n\nEssentially, this is a time-saver so that you don't have to create a manifest file that only contains a single `require_tree` directive.\n\n## <a name=\"command-line\"></a> Using via Command-Line\n\nUse `npm install -g asset-smasher` to install the `asset-smasher` command-line tool globally.\n\n      asset-smasher --help\n\n        Usage: asset-smasher [options] <output dir>\n\n        Options:\n\n          -h, --help               output usage information\n          -V, --version            output the version number\n          --compress               compress/minify the generated files\n          --hash                   generate versions of the files with md5 hashes in the name\n          --gzip                   generate gzipped versions of the compiled files\n          --hashVersion <version>  invalidate all assets without changing file contents [1.0]\n          --only <pattern,...>     only process the files matching these glob patterns (relative to any of the paths) [**/*]\n          --paths <path,...>       list of paths to look for assets [.]\n          --prefix <prefix>        prefix to append to logical paths when constructing urls. use if output dir is not served from the root of your web app []\n          --helpers <js_file>      a .js module of helper functions require()s to expose to transforms []\n          --plugins <js_file>      a .js plugin module []\n          --amd                    enable AMD support (give anonymous modules names, support /** @amd */ pragma comments)\n          --verbose                output more verbose information about what is going on to the console\n          --noclean                do not delete the output directory before generating files (by default it will be removed first)\n\n        If --only is not specified, *all* files in the --paths will be processed.\n        If --hash is specified, a map.json file will be generated that maps the unmangled file name to the hashed one.\n\n        Be careful that your shell doesn't expand glob patterns when passing them as arguments. To be safe, surround the argument with quotes.\n\n        Examples:\n\n          Compile all assets in the current directory to /home/me/compiledAssets\n\n            $ asset-smasher /home/me/compiledAssets\n\n          Something similar to what the Rails asset pipeline does by default\n\n            $ asset-smasher --compress --hash --gzip --prefix /assets \\\n                --paths ./js,./css,./images \\\n                --only \"**/*.jpg,**/*.gif,**/*.png,application.js.mf,application.css.mf\" ./public/assets\n\n          Compile assets, providing some custom helpers to the transformation\n\n            $ asset-smasher --helpers helpers.js output\n\n### <a name=\"cli-helpers\"></a> Helpers\n\nThere is a built-in `asset_path` helper that can be used to get the \"real\" (i.e. with hashed file name) path of an asset.  E.g. `asset_path('css/myFile.css')` might return `'/assets/css/myFile-c89cba7b7df028e65cb01d86f4d27077.css`.\n\nSome transformers (e.g. the `.ejs` one) take in a set of local variables that they can use during transformation. You can pass in the path to a JavaScript module whose exports will be included in this set of variables.\n\nYou can use this, for example, to set configuration parameters in your JS files:\n\n**helper.js**\n\n    exports.serviceUrl = 'http://my.service/';\n\n**config.js.ejs**\n\n    //...\n    var serviceUrl = '<%= serviceUrl %>';\n    var cssLocation = '<%= asset_path('css/myFile.css') %>';\n    //...\n\n**Execution**\n\n    $ asset-smasher --helpers helper.js --only config.js.ejs,css/myFile.css .\n    $ cat config.js\n    var serviceUrl = 'http://my.service/';\n    var cssLocation = '/assets/css/myFile-c89cba7b7df028e65cb01d86f4d27077.css';\n\n\n### <a name=\"cli-plugins\"></a> Plugins\n\nIf there's a type of file you want to pre-process that is not natively supported by Asset Smasher, you can add it using a plugin file.\n\nFor an example of what the transformer classes look like, look in the `lib/compilation/transforms` directory\n\nIf a plugin module is passed (via `--plugins`), it will be `require()`d and then invoked, being passed in the asset smasher library (the module defined in `lib/asset-smasher.js`)\n\nTo register your transformer, just add another entry to the `transforms` object.\n\nE.g.\n\n**my_plugin.js**\n\n    module.exports = function(assetSmasher) {\n       // A stupid transformer that adds \"foo\" to the start and end of the contents\n       var FooTransform = function FooTransform(options) {\n         this.options = options || {};\n       };\n       FooTransform.prototype = {\n         extensions:function () {\n           return ['.foo'];\n         },\n         shouldTransform:function (file) {\n           return path.extname(file) === '.foo';\n         },\n         transformedFileName:function (file) {\n           return path.basename(file, '.foo');\n         },\n         transform:function (asset, cb) {\n           // Transform the file name\n           asset.logicalName = this.transformedFileName(asset.logicalName);\n           // Get the contents\n           var contents = asset.contents;\n           if (Buffer.isBuffer(contents)) {\n             contents = contents.toString('utf-8');\n           }\n           // Compile the contents\n           asset.contents = 'foo-' + contents + '-foo';\n           cb();\n         }\n       };\n\n       assetSmasher.transforms.Foo = FooTransform;\n    };\n\nIf you then invoke `asset-smasher` with `--plugins my_plugin.js` it will automatically transform `*.foo` files.\n\n## <a name=\"express-middleware\"></a> Using via Express Middleware\n\nAsset smasher exposes an `express` middleware that can:\n\n- Serve your assets un-merged/mangled in development mode.\n- Serve precompiled assets (with hashed file names) in production mode.\n\nThe middleware takes in the same arguments as the `Smasher` constructor, with a few extras:\n\n- `serve` - boolean (or object - see more below) indiacating whether the middleware should serve the asset files.  Usualy set this to `true` in development, `false` in production (e.g if you're using precompiled assets)\n    - An object can be passed in with the following properties to control the serving behavior. If `true` is passed in, the default values here will be used\n        - `individual` - Whether the individual (`true`) or merged files (`false`) should be served. Default `true`.\n- `assetMapLocation` - path to the `map.json` generated by the command-line `asset-smasher` util.  This allows the helper methods to determine what the hashed file names were\n\nThe middleware exposes two helpers to your views:\n\n- `js_asset(logicalPath)` - Render a `<script>` tag for the specified JS asset. When `serve` is true, this will \"explode\" manifests and write out a separate `<script>` for each required file.  This makes debugging much easier.\n- `css_asset(logicalPath)` - Render a `<link>` tag for the specified CSS asset.  Same thing happens when `serve` is true as with `js_asset`.\n- `raw_asset(logicalPath)` - Return the path to the asset.\n\nYou *must* include the middleware **before** the Express routing middleware. Otherwise the asset helper functions will not be available for your view to use.\n\n### Example\n\n    var assetSmasher = require('asset-smasher');\n\n**Middleware config (Dev)**\n\n    app.use(assetSmasher.middleware({\n      serve: true,\n      paths: [path.join(__dirname, 'assetDir1'), path.join(__dirname, 'assetDir2')],\n      prefix: '/assets',\n      outputTo: path.join(__dirname, 'tmp')\n    }));\n\n**Middleware config (Prod)**\n\n    app.use(assetSmasher.middleware({\n      serve: false,\n      prefix: '/assets',\n      assetMapLocation: path.join(__dirname, 'public/assets/map.json')\n    }));\n\n**Middleware config (Alternate Prod config not using precompilation, but instead compile on first access)**\n\nNote that if you use this configuration, you will **not** be able to use \"hashed\" filenames.\n\n    app.use(express.staticCache());\n    app.use(express.static(path.join(__dirname, 'public')));\n    app.use(assetSmasher.middleware({\n      serve: {\n        individual: false\n      },\n      paths: [path.join(__dirname, 'assetDir1'), path.join(__dirname, 'assetDir2')],\n      compress: true,\n      prefix: '/assets',\n      // This will make the files be served once by asset smasher\n      // and then by the express \"static\" middleware thereafter.\n      // You can then also use something like \"staticCache\" to cache the files if you're not\n      // using a reverse proxy cache on the public dir\n      outputTo: path.join(__dirname, 'public/assets')\n    }));\n\n**View (ejs here, but could be others)**\n\n    <!DOCTYPE html>\n    <html>\n    <head>\n      <title>Test</title>\n      <%- css_asset('application.css') %>\n      <%- js_asset('application.js') %>\n    </head>\n    <body>\n      This is a test\n    </body>\n    </html>\n\n## <a name=\"programmatic-interface\"></a> Using via Programmatic Interface\n\nYou can invoke Asset Smasher programmatically by `require`ing it.  You can also plug in additional transformers this way.\n\nThe `Smasher` object has the following methods:\n\n - `compileAssets(cb)` - Find and compile all the assets.\n - `compileSingleAsset(assetFilePath, cb)` - Compile a single asset (assetFilePath is the actual path to the file, not a logical path)\n - `findAssets(cb)` - Find, but don't compile the assets.  Good for determining dependency graph without compiling.\n - `getAssetByLogicalPath(logicalPath)` - Get information about an asset by its logical path.  Only call this after finding/compiling assets.\n - `getHashedFileMapping()` - When `hash` is true, this returns a mapping of logical path to \"hashed\" logical path.  This object is what the command-line tool outputs to `map.json`. Only call this after finding/compiling assets.\n - `getRequiredLogicalPathsFor(asset)` - Get the logical paths of the assets that should be merged into the specified asset (populated for `.mf` files). Only call this after finding/compiling assets.\n - `getProcessingOrderLogicalPaths()` - Get a list of the order in which assets should be processed in order to satisfy all dependencies. Only call this after finding/compiling assets.\n - `reset()` - Reset the asset metadata.\n\nThe `Asset` object returned by `getAssetByLogicalPath` has the following properties (and one method):\n\n - `logicalPath` - The logical path\n - `hashedPath` - If `hash` is true, the hashed filename path, otherwise the same as `logicalPath`\n - `assetFilePath` - The full path to the actual source asset\n - `compiled` - Whether the asset has been compiled\n - `compiledAssetFilePath` - The full path to the compiled asset file\n - `reset()` - Set the asset back to its before-compile state (clear out contents, set name back to pre-transform name)\n\n**Example**\n\n    var assetSmasher = require('asset-smasher');\n    var Smasher = assetSmasher.Smasher;\n\n    // Plug in a custom transformer\n    assetSmasher.transforms['MyAwesomeFormat'] = require('myAwesomeFormatTransformer');\n\n    var sm = new Smasher({\n      paths:['/path/one', '/path/two'],\n      only:['**/*.{jpg,gif,png}', 'application.js.mf', 'application.css.mf'],\n      prefix:'/assets',\n      compress:true,\n      hash:true,\n      hashVersion:'1.0',\n      gzip:true,\n      outputTo:__dirname + '/public/assets',\n      helpers:{\n       my: 'helper',\n       another: 'helper'\n      },\n      amd:false,\n      verbose:true,\n      noclean:true\n    });\n    sm.compileAssets(function(err) {\n      if(err) {\n        console.log('An error occurred', err);\n      } else {\n        console.log('Compilation done!');\n      }\n    });\n\n## <a name=\"transformer-notes\"></a> Transformer Notes\n\nTo use a transformer you must install the associated node module.\n - `.coffee` - `npm install coffee-script`\n - `.dust` - `npm install dustjs-linkedin`\n - `.ejs` - `npm install ejs`\n - `.hbs` - `npm install handlebars`\n - `.jsx` - `npm install react-tools`\n - `.less` - `npm install less`\n - `.styl` - `npm install stylus`\n\n### <a name=\"tn-amd\"></a> AMD Support\n\nAsset-smasher can wrap JavaScript files that follow the [CommonJS](http://wiki.commonjs.org/wiki/Modules) module format with [Asynchronous Module Definition](https://github.com/amdjs/amdjs-api/wiki/AMD) `define` calls.\n\nTo enable the wrapping of a JavaScript file, pass the `--amd` option to `asset-smahser` and put the following at the top of it:\n\n    /** @amd */\n\nThis will cause asset smasher to:\n - Parse the contents of the file for any `require` calls\n - Wrap the contents of the file with a `define` call where the module id is the logical path of the file (minus `.js`) and the dependencies are anything that was `require`d. `require`, `exports`, and `module` are always dependencies.\n\nExample (say the file is in `scripts/foo.js`)\n\n    /** @amd */\n    var x = require('x');\n    var y = require('../y');\n    \n    exports.foo = function (bar) {\n      return x(bar) + y(bar);\n    };\n\nThis will be transformed into:\n\n    define('scripts/foo',\n           ['require', 'exports', 'module', 'x', '../y'],\n           function (require, exports, module) {\n      var x = require('x');\n      var y = require('../y');\n      \n      exports.foo = function (bar) {\n        return x(bar) + y(bar);\n      };\n    });\n\nThe `/** @amd */` pragma can also take a comma-delimeted list of module ids after it, which will be added to the list of dependencies. This is useful when you need a dependency to be loaded, but aren't using it directly (e.g. a jQuery plugin)\n\nExample (say the file is in `scripts/foo.js`)\n\n    /** @amd ./foo,./bar,./baz */\n    var x = require('x');\n    // ...\n\nWill be transformed into\n\n    define('scripts/foo',\n           ['require', 'exports', 'module', 'x', './foo', './bar', './baz'],\n           function (require, exports, module) {\n      var x = require('x');\n      // ...\n    });\n\nIf you have any anonymous AMD modules specified (i.e. with no module id) or use the simplified commonjs wrapper, the `--amd` option will give these modules names (relative to the asset path root)\n\nExample (say the file is in `modules/test.js`)\n\n    define(['foo','bar'], function (foo, bar) {\n      // ...\n    });\n\nWill be transformed into\n\n    define('modules/test', ['foo', 'bar'], function (foo, bar) {\n      // ...\n    });\n\nAnd\n\n    define(function (require, exports, module) {\n      var x = require('x');\n      //...\n    });\n\nWill be transformed into\n\n    define('modules/test', ['require', 'exports', 'module', 'x'], function (require, exports, module) {\n      var x = require('x');\n      //...\n    });\n\nYou can then use an AMD loader (like [require.js](http://requirejs.org/)) to load the modules.\n\n### <a name=\"tn-less-styl\"></a> LESS/Stylus\n\n- Any `@include/@import` paths are *relative to the path that the file is in*.\n- Any `@include/@import`ed files will *not* be processed individually by Asset Smasher (i.e. you can't `@include` a LESS file that is preprocessed by ejs)\n\n### <a name=\"tn-ejs\"></a> ejs\n\n- Any registered helpers will be exposed as global variables to the `ejs` transform.\n- The built-in `asset_paths` helper can be used here.\n\n### <a name=\"tn-dust-hbs\"></a> dust and Handlebars\n\n- The name of the template will be the template's \"logical path\" (minus the asset path it is in), minus the `.js.dust` or `.js.hbs` file extension.\n    - E.g. `/my/templates/test.js.dust`'s template name will be `test` (assuming `/my/templates` is the asset path)\n","readmeFilename":"README.md","_id":"asset-smasher@0.3.1","dist":{"shasum":"ec34e5b5b96ce9c30b67c2f0234789baca70a346","tarball":"https://registry.npmjs.org/asset-smasher/-/asset-smasher-0.3.1.tgz","integrity":"sha512-mhH/9tGXJsv5ut0LcDm7Cogy1yEuzTffy5jg+DX+VoZgPhWXhRCvIaHECGM31oEBG9NQ/FMoZS4XotYEz9SDig==","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIQDsmQvt/7Rnw9gQmsnpBIR/TsXgk/dZoduPsHoTERDNHAIgIA5TClXUUyGsEvIkAu4WQExxtp+W8ak4EAl9oljPuug="}]},"_from":".","_npmVersion":"1.2.32","_npmUser":{"name":"jriecken","email":"jriecken@gmail.com"},"maintainers":[{"name":"jriecken","email":"jriecken@gmail.com"}]},"0.3.2":{"name":"asset-smasher","description":"Asset pre-processor, merger, and compressor.","version":"0.3.2","author":{"name":"Jim Riecken","email":"jriecken@gmail.com"},"keywords":["asset","compress","merge","preprocess"],"license":{"type":"MIT","url":"http://github.com/jriecken/asset-smasher/raw/master/LICENSE"},"repository":{"type":"git","url":"git://github.com/jriecken/asset-smasher.git"},"bugs":{"url":"http://github.com/jriecken/asset-smasher/issues"},"main":"./lib/asset-smasher.js","bin":{"asset-smasher":"./bin/asset-smasher"},"dependencies":{"async":"0.2.6","commander":"1.1.1","dependency-graph":"0.1.0","glob":"3.1.21","mkdirp":"0.3.5","minimatch":"0.2.11","rimraf":"2.1.4","send":"0.1.0","uglify-js":"2.2.5","underscore":"1.4.4","ycssmin":"1.0.1"},"optionalDependencies":{},"devDependencies":{},"engines":{"node":">= 0.6.0"},"readme":"# Asset Smasher\n\nAsset pre-processor, merger, and compressor for Node.js\n\n- [Structuring Your Assets](#structure-assets)\n    - [Manifest Files](#manifest-files)\n    - [Manifest Directories](#manifest-directories)\n- [Using via Command Line](#command-line)\n    - [Helpers](#cli-helpers)\n    - [Plugins](#cli-plugins)\n- [Using via Express Middleware](#express-middleware)\n- [Using via Programmatic Interface](#programmatic-interface)\n- [Transformer Notes](#transformer-notes)\n    - [AMD Support](#tn-amd)\n    - [LESS/Stylus](#tn-less-styl)\n    - [ejs](#tn-ejs)\n    - [dust and Handlebars](#tn-dust-hbs)\n\n## Overview\n\nAsset Smasher is a command-line tool, express middleware, and programmatic interface for:\n\n- Pre-processing and transforming files down to plain JavaScript and CSS.\n    - `.coffee` - Compile [CoffeeScript](http://coffeescript.org/) into JavaScript\n    - `.ejs` - Run a file through [EJS](https://github.com/visionmedia/ejs) (e.g. to populate configuration parameters into a JavaScript file)\n    - `.less` - Compile [Less](http://lesscss.org/) into CSS\n    - `.styl` - Compile [Stylus](http://learnboost.github.io/stylus/) into CSS\n    - `.hbs` - Precompile [Handlebars](http://handlebarsjs.com/) templates into JavaScript files that register them with `Handlebars.templates`.\n    - `.dust` - Precompile [Dust](http://linkedin.github.io/dustjs/) templates into JavaScript files that register them for use with `dust.render`.\n    - `.jsx` - Transform JSX files (for use with [React](http://facebook.github.io/react/)) into JavaScript files.\n    - Can wrap CommonJS-style JavaScript files with [AMD](https://github.com/amdjs/amdjs-api/wiki/AMD) `define` calls.\n    - Processors can be chained together.  E.g `test.js.hbs.ejs` (run Handlebars template through EJS, then compile it)\n    - Additional processors can be plugged in.\n- Merging files together using Manifest files (`.mf`) with dependency management directives similar to Sprockets.\n    - `require` - Require a single file\n    - `require_dir` - Require all the files in a specific directory\n    - `require_tree` - Require all the files in a specific directory (and subdirectories)\n- Compressing, gzipping, and generating hashed file names.\n    - Compress JavaScript files with `uglify-js`\n    - Compress CSS files with `ycssmin`\n    - Generate Gzipped versions of files\n    - Include a MD5 hash of the file's contents in the file name. `myAsset.js` -> `myAsset-c89cba7b7df028e65cb01d86f4d27077.js`\n        - `asset_path` helper that can be used to reference the hashed name.\n\nIt's released under the [MIT](http://en.wikipedia.org/wiki/MIT_License) license.\n\n## <a name=\"structure-assets\"></a> Structuring Your Assets\n\nAsset Smasher has the concept of \"asset paths\".  These are locations in which your asset files will be located, and from which any relative asset paths will be rooted to.\n\nThe simplest structure has one asset path.\n\nE.g.\n\n    Asset Paths\n    -----------\n     - app\n\n    File Structure\n    --------------\n    app/\n      js/\n      css/\n      images/\n\nA more complicated structure might be\n\n    Asset Paths\n    -----------\n     - app\n     - lib\n     - vendor\n\n    File Structure\n    --------------\n    app/\n      js/\n      css/\n      images/\n    lib/\n      js/\n      css/\n      images/\n    vendor/\n      js/\n      css/\n      images/\n\nBoth of these examples will result in a compiled structure of\n\n    js/\n    css/\n    images/\n\n### <a name=\"manifest-files\"></a> Manifest Files\n\nManifest (`.mf`) files are used to merge many assets into a single resulting file. The file should be named with the resulting file type before the `.mf` extension (e.g. `manifest.css.mf` or `manifest.js.mf`. *Manifest files can `require` other manifest files*\n\nOnly files that will be transformed down to a file of a manifest's \"type\" (e.g. `manifest.css.mf` => `.css`, `manifest.js.mf` => `.js`) will be included. This means that, for example, if you `require_dir` a directory in a JavaScript manifest that happens to contain both JavaScript and CSS, only the JavaScript files will be required.\n\nA simple manifest file might look like\n\n    # A comment here\n    require \"./one.js\"\n    require_dir \"./subdir1\"\n    #\n    # Another comment\n    require_tree \"./subdir2\"\n\n**Directives:**\n\n<table border=\"1\" cellpadding=\"5\" cellspacing=\"0\" width=\"100%\">\n <thead>\n  <tr><th width=\"15%\">Directive</th><th width=\"85%\">Description</th></tr>\n </thead>\n <tbody>\n  <tr>\n    <td><code>require \"[path]\"</code></td>\n    <td>\n      <strong>Include a single file</strong>\n      <ul>\n       <li>\n         If the path starts with <code>\"/\"</code>, <code>\"../\"</code>, or <code>\"./\"</code>, process and include the specified file.  The file <em>must</em> be\n         inside one of the configured asset paths.\n       </li>\n       <li>\n         If the path does not start with <code>\"/\"</code>, <code>\"../\"</code>, or <code>\"./\"</code>, the file will be searched for in all of the configured\n         asset paths.  E.g. if there are asset paths <code>one</code> and <code>two</code> defined, <code>require \"js/test.js\"</code>\n         will look for <code>one/js/test.js</code> and then <code>two/js/test.js</code> stopping when it finds a matching file.\n       </li>\n       <li>\n         The filename part of the path does not have to include the whole extension.  E.g <code>require \"test\"</code>\n         finds the first file that matches the name in the asset paths (for example <code>test.js.ejs</code>)\n       </li>\n       <li>\n         If the file does not exist/can't be resolved/isn't of the right type for the manifest, it will be ignored (will be logged in verbose mode).\n       </li>\n      </ul>\n    </td>\n  </tr>\n  <tr>\n    <td><code>require_dir \"[path]\"</code></td>\n    <td>\n      <strong>Include all the files in a directory</strong>\n      <ul>\n       <li>\n         The path must be absolute, or relative to the current directory.  E.g. you can do <code>require_dir \"../some/other/dir\"</code>\n         but not <code>require_dir \"somedir\"</code>\n       </li>\n       <li>\n         If using absolute paths, or <code>\"..\"</code> in your paths, the resulting directory needs to be inside one of the configured asset paths.\n       </li>\n       <li>\n         If the directory does not exist, it will be ignored (will be logged in verbose mode).\n       </li>\n      </ul>\n    </td>\n  </tr>\n  <tr>\n    <td><code>require_tree \"[path]\"</code></td>\n    <td>\n      <strong>Include the files in a directory recursively</strong>\n      <ul>\n        <li>The rules for <code>require_tree</code> are the same as the rules for <code>require_dir</code></li>\n      </ul>\n    </td>\n  </tr>\n </tbody>\n</table>\n\n### <a name=\"manifest-directories\"></a> Manifest Directories\n\nIf you create a directory, for example named `foo.js.mf` and put a bunch of javascript files in it (or any subdirectories under it), `asset-smasher` will (recursively) take all the files inside and merge them into `foo.js`.\n\nEssentially, this is a time-saver so that you don't have to create a manifest file that only contains a single `require_tree` directive.\n\n## <a name=\"command-line\"></a> Using via Command-Line\n\nUse `npm install -g asset-smasher` to install the `asset-smasher` command-line tool globally.\n\n      asset-smasher --help\n\n        Usage: asset-smasher [options] <output dir>\n\n        Options:\n\n          -h, --help               output usage information\n          -V, --version            output the version number\n          --compress               compress/minify the generated files\n          --hash                   generate versions of the files with md5 hashes in the name\n          --gzip                   generate gzipped versions of the compiled files\n          --hashVersion <version>  invalidate all assets without changing file contents [1.0]\n          --only <pattern,...>     only process the files matching these glob patterns (relative to any of the paths) [**/*.*]\n          --paths <path,...>       list of paths to look for assets [.]\n          --prefix <prefix>        prefix to append to logical paths when constructing urls. use if output dir is not served from the root of your web app []\n          --helpers <js_file>      a .js module of helper functions require()s to expose to transforms []\n          --plugins <js_file>      a .js plugin module []\n          --amd                    enable AMD support (give anonymous modules names, support /** @amd */ pragma comments)\n          --verbose                output more verbose information about what is going on to the console\n          --noclean                do not delete the output directory before generating files (by default it will be removed first)\n\n        If --only is not specified, *all* files in the --paths will be processed.\n        If --hash is specified, a map.json file will be generated that maps the unmangled file name to the hashed one.\n\n        Be careful that your shell doesn't expand glob patterns when passing them as arguments. To be safe, surround the argument with quotes.\n\n        Examples:\n\n          Compile all assets in the current directory to /home/me/compiledAssets\n\n            $ asset-smasher /home/me/compiledAssets\n\n          Something similar to what the Rails asset pipeline does by default\n\n            $ asset-smasher --compress --hash --gzip --prefix /assets \\\n                --paths ./js,./css,./images \\\n                --only \"**/*.jpg,**/*.gif,**/*.png,application.js.mf,application.css.mf\" ./public/assets\n\n          Compile assets, providing some custom helpers to the transformation\n\n            $ asset-smasher --helpers helpers.js output\n\n### <a name=\"cli-helpers\"></a> Helpers\n\nThere is a built-in `asset_path` helper that can be used to get the \"real\" (i.e. with hashed file name) path of an asset.  E.g. `asset_path('css/myFile.css')` might return `'/assets/css/myFile-c89cba7b7df028e65cb01d86f4d27077.css`.\n\nSome transformers (e.g. the `.ejs` one) take in a set of local variables that they can use during transformation. You can pass in the path to a JavaScript module whose exports will be included in this set of variables.\n\nYou can use this, for example, to set configuration parameters in your JS files:\n\n**helper.js**\n\n    exports.serviceUrl = 'http://my.service/';\n\n**config.js.ejs**\n\n    //...\n    var serviceUrl = '<%= serviceUrl %>';\n    var cssLocation = '<%= asset_path('css/myFile.css') %>';\n    //...\n\n**Execution**\n\n    $ asset-smasher --helpers helper.js --only config.js.ejs,css/myFile.css .\n    $ cat config.js\n    var serviceUrl = 'http://my.service/';\n    var cssLocation = '/assets/css/myFile-c89cba7b7df028e65cb01d86f4d27077.css';\n\n\n### <a name=\"cli-plugins\"></a> Plugins\n\nIf there's a type of file you want to pre-process that is not natively supported by Asset Smasher, you can add it using a plugin file.\n\nFor an example of what the transformer classes look like, look in the `lib/compilation/transforms` directory\n\nIf a plugin module is passed (via `--plugins`), it will be `require()`d and then invoked, being passed in the asset smasher library (the module defined in `lib/asset-smasher.js`)\n\nTo register your transformer, just add another entry to the `transforms` object.\n\nE.g.\n\n**my_plugin.js**\n\n    module.exports = function(assetSmasher) {\n       // A stupid transformer that adds \"foo\" to the start and end of the contents\n       var FooTransform = function FooTransform(options) {\n         this.options = options || {};\n       };\n       FooTransform.prototype = {\n         extensions:function () {\n           return ['.foo'];\n         },\n         shouldTransform:function (file) {\n           return path.extname(file) === '.foo';\n         },\n         transformedFileName:function (file) {\n           return path.basename(file, '.foo');\n         },\n         transform:function (asset, cb) {\n           // Transform the file name\n           asset.logicalName = this.transformedFileName(asset.logicalName);\n           // Get the contents\n           var contents = asset.contents;\n           if (Buffer.isBuffer(contents)) {\n             contents = contents.toString('utf-8');\n           }\n           // Compile the contents\n           asset.contents = 'foo-' + contents + '-foo';\n           cb();\n         }\n       };\n\n       assetSmasher.transforms.Foo = FooTransform;\n    };\n\nIf you then invoke `asset-smasher` with `--plugins my_plugin.js` it will automatically transform `*.foo` files.\n\n## <a name=\"express-middleware\"></a> Using via Express Middleware\n\nAsset smasher exposes an `express` middleware that can:\n\n- Serve your assets un-merged/mangled in development mode.\n- Serve precompiled assets (with hashed file names) in production mode.\n\nThe middleware takes in the same arguments as the `Smasher` constructor, with a few extras:\n\n- `serve` - boolean (or object - see more below) indiacating whether the middleware should serve the asset files.  Usualy set this to `true` in development, `false` in production (e.g if you're using precompiled assets)\n    - An object can be passed in with the following properties to control the serving behavior. If `true` is passed in, the default values here will be used\n        - `individual` - Whether the individual (`true`) or merged files (`false`) should be served. Default `true`.\n- `assetMapLocation` - path to the `map.json` generated by the command-line `asset-smasher` util.  This allows the helper methods to determine what the hashed file names were\n\nThe middleware exposes two helpers to your views:\n\n- `js_asset(logicalPath)` - Render a `<script>` tag for the specified JS asset. When `serve` is true, this will \"explode\" manifests and write out a separate `<script>` for each required file.  This makes debugging much easier.\n- `css_asset(logicalPath)` - Render a `<link>` tag for the specified CSS asset.  Same thing happens when `serve` is true as with `js_asset`.\n- `raw_asset(logicalPath)` - Return the path to the asset.\n\nYou *must* include the middleware **before** the Express routing middleware. Otherwise the asset helper functions will not be available for your view to use.\n\n### Example\n\n    var assetSmasher = require('asset-smasher');\n\n**Middleware config (Dev)**\n\n    app.use(assetSmasher.middleware({\n      serve: true,\n      paths: [path.join(__dirname, 'assetDir1'), path.join(__dirname, 'assetDir2')],\n      prefix: '/assets',\n      outputTo: path.join(__dirname, 'tmp')\n    }));\n\n**Middleware config (Prod)**\n\n    app.use(assetSmasher.middleware({\n      serve: false,\n      prefix: '/assets',\n      assetMapLocation: path.join(__dirname, 'public/assets/map.json')\n    }));\n\n**Middleware config (Alternate Prod config not using precompilation, but instead compile on first access)**\n\nNote that if you use this configuration, you will **not** be able to use \"hashed\" filenames.\n\n    app.use(express.staticCache());\n    app.use(express.static(path.join(__dirname, 'public')));\n    app.use(assetSmasher.middleware({\n      serve: {\n        individual: false\n      },\n      paths: [path.join(__dirname, 'assetDir1'), path.join(__dirname, 'assetDir2')],\n      compress: true,\n      prefix: '/assets',\n      // This will make the files be served once by asset smasher\n      // and then by the express \"static\" middleware thereafter.\n      // You can then also use something like \"staticCache\" to cache the files if you're not\n      // using a reverse proxy cache on the public dir\n      outputTo: path.join(__dirname, 'public/assets')\n    }));\n\n**View (ejs here, but could be others)**\n\n    <!DOCTYPE html>\n    <html>\n    <head>\n      <title>Test</title>\n      <%- css_asset('application.css') %>\n      <%- js_asset('application.js') %>\n    </head>\n    <body>\n      This is a test\n    </body>\n    </html>\n\n## <a name=\"programmatic-interface\"></a> Using via Programmatic Interface\n\nYou can invoke Asset Smasher programmatically by `require`ing it.  You can also plug in additional transformers this way.\n\nThe `Smasher` object has the following methods:\n\n - `compileAssets(cb)` - Find and compile all the assets.\n - `compileSingleAsset(assetFilePath, cb)` - Compile a single asset (assetFilePath is the actual path to the file, not a logical path)\n - `findAssets(cb)` - Find, but don't compile the assets.  Good for determining dependency graph without compiling.\n - `getAssetByLogicalPath(logicalPath)` - Get information about an asset by its logical path.  Only call this after finding/compiling assets.\n - `getHashedFileMapping()` - When `hash` is true, this returns a mapping of logical path to \"hashed\" logical path.  This object is what the command-line tool outputs to `map.json`. Only call this after finding/compiling assets.\n - `getRequiredLogicalPathsFor(asset)` - Get the logical paths of the assets that should be merged into the specified asset (populated for `.mf` files). Only call this after finding/compiling assets.\n - `getProcessingOrderLogicalPaths()` - Get a list of the order in which assets should be processed in order to satisfy all dependencies. Only call this after finding/compiling assets.\n - `reset()` - Reset the asset metadata.\n\nThe `Asset` object returned by `getAssetByLogicalPath` has the following properties (and one method):\n\n - `logicalPath` - The logical path\n - `hashedPath` - If `hash` is true, the hashed filename path, otherwise the same as `logicalPath`\n - `assetFilePath` - The full path to the actual source asset\n - `compiled` - Whether the asset has been compiled\n - `compiledAssetFilePath` - The full path to the compiled asset file\n - `reset()` - Set the asset back to its before-compile state (clear out contents, set name back to pre-transform name)\n\n**Example**\n\n    var assetSmasher = require('asset-smasher');\n    var Smasher = assetSmasher.Smasher;\n\n    // Plug in a custom transformer\n    assetSmasher.transforms['MyAwesomeFormat'] = require('myAwesomeFormatTransformer');\n\n    var sm = new Smasher({\n      paths:['/path/one', '/path/two'],\n      only:['**/*.{jpg,gif,png}', 'application.js.mf', 'application.css.mf'],\n      prefix:'/assets',\n      compress:true,\n      hash:true,\n      hashVersion:'1.0',\n      gzip:true,\n      outputTo:__dirname + '/public/assets',\n      helpers:{\n       my: 'helper',\n       another: 'helper'\n      },\n      amd:false,\n      verbose:true,\n      noclean:true\n    });\n    sm.compileAssets(function(err) {\n      if(err) {\n        console.log('An error occurred', err);\n      } else {\n        console.log('Compilation done!');\n      }\n    });\n\n## <a name=\"transformer-notes\"></a> Transformer Notes\n\nTo use a transformer you must install the associated node module.\n - `.coffee` - `npm install coffee-script`\n - `.dust` - `npm install dustjs-linkedin`\n - `.ejs` - `npm install ejs`\n - `.hbs` - `npm install handlebars`\n - `.jsx` - `npm install react-tools`\n - `.less` - `npm install less`\n - `.styl` - `npm install stylus`\n\n### <a name=\"tn-amd\"></a> AMD Support\n\nAsset-smasher can wrap JavaScript files that follow the [CommonJS](http://wiki.commonjs.org/wiki/Modules) module format with [Asynchronous Module Definition](https://github.com/amdjs/amdjs-api/wiki/AMD) `define` calls.\n\nTo enable the wrapping of a JavaScript file, pass the `--amd` option to `asset-smahser` and put the following at the top of it:\n\n    /** @amd */\n\nThis will cause asset smasher to:\n - Parse the contents of the file for any `require` calls\n - Wrap the contents of the file with a `define` call where the module id is the logical path of the file (minus `.js`) and the dependencies are anything that was `require`d. `require`, `exports`, and `module` are always dependencies.\n\nExample (say the file is in `scripts/foo.js`)\n\n    /** @amd */\n    var x = require('x');\n    var y = require('../y');\n    \n    exports.foo = function (bar) {\n      return x(bar) + y(bar);\n    };\n\nThis will be transformed into:\n\n    define('scripts/foo',\n           ['require', 'exports', 'module', 'x', '../y'],\n           function (require, exports, module) {\n      var x = require('x');\n      var y = require('../y');\n      \n      exports.foo = function (bar) {\n        return x(bar) + y(bar);\n      };\n    });\n\nThe `/** @amd */` pragma can also take a comma-delimeted list of module ids after it, which will be added to the list of dependencies. This is useful when you need a dependency to be loaded, but aren't using it directly (e.g. a jQuery plugin)\n\nExample (say the file is in `scripts/foo.js`)\n\n    /** @amd ./foo,./bar,./baz */\n    var x = require('x');\n    // ...\n\nWill be transformed into\n\n    define('scripts/foo',\n           ['require', 'exports', 'module', 'x', './foo', './bar', './baz'],\n           function (require, exports, module) {\n      var x = require('x');\n      // ...\n    });\n\nIf you have any anonymous AMD modules specified (i.e. with no module id) or use the simplified commonjs wrapper, the `--amd` option will give these modules names (relative to the asset path root)\n\nExample (say the file is in `modules/test.js`)\n\n    define(['foo','bar'], function (foo, bar) {\n      // ...\n    });\n\nWill be transformed into\n\n    define('modules/test', ['foo', 'bar'], function (foo, bar) {\n      // ...\n    });\n\nAnd\n\n    define(function (require, exports, module) {\n      var x = require('x');\n      //...\n    });\n\nWill be transformed into\n\n    define('modules/test', ['require', 'exports', 'module', 'x'], function (require, exports, module) {\n      var x = require('x');\n      //...\n    });\n\nYou can then use an AMD loader (like [require.js](http://requirejs.org/)) to load the modules.\n\n### <a name=\"tn-less-styl\"></a> LESS/Stylus\n\n- Any `@include/@import` paths are *relative to the path that the file is in*.\n- Any `@include/@import`ed files will *not* be processed individually by Asset Smasher (i.e. you can't `@include` a LESS file that is preprocessed by ejs)\n\n### <a name=\"tn-ejs\"></a> ejs\n\n- Any registered helpers will be exposed as global variables to the `ejs` transform.\n- The built-in `asset_paths` helper can be used here.\n\n### <a name=\"tn-dust-hbs\"></a> dust and Handlebars\n\n- The name of the template will be the template's \"logical path\" (minus the asset path it is in), minus the `.js.dust` or `.js.hbs` file extension.\n    - E.g. `/my/templates/test.js.dust`'s template name will be `test` (assuming `/my/templates` is the asset path)\n","readmeFilename":"README.md","_id":"asset-smasher@0.3.2","dist":{"shasum":"3023a5262a604c5df9c83a5ba9e4ccf104ec8294","tarball":"https://registry.npmjs.org/asset-smasher/-/asset-smasher-0.3.2.tgz","integrity":"sha512-ZwZUZx1SfdKKqTxQvKzYJUJtjQsertH3MlruknYO6C84DpngGIgKFayRB4GAAvnFRXWckEWRhDeSwmgUPLc8iQ==","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIQCsKvHxqU7wuWS4OeDcQagjHSNmlobwIeLdHpMo35bR+wIgVPtLSIdzkN8taAbrwjKS6XkIynS3Xp8asocTu5EE75s="}]},"_from":".","_npmVersion":"1.2.32","_npmUser":{"name":"jriecken","email":"jriecken@gmail.com"},"maintainers":[{"name":"jriecken","email":"jriecken@gmail.com"}]}},"readme":"# Asset Smasher\n\nAsset pre-processor, merger, and compressor for Node.js\n\n- [Structuring Your Assets](#structure-assets)\n    - [Manifest Files](#manifest-files)\n- [Using via Command Line](#command-line)\n    - [Helpers](#cli-helpers)\n    - [Plugins](#cli-plugins)\n- [Using via Express Middleware](#express-middleware)\n- [Using via Programmatic Interface](#programmatic-interface)\n- [Transformer Notes](#transformer-notes)\n    - [LESS](#tn-less)\n    - [ejs](#tn-ejs)\n    - [dust and Handlebars](#tn-dust-hbs)\n\n## Overview\n\nAsset Smasher is a command-line tool, express middleware, and programmatic interface for:\n\n- Pre-processing and transforming files down to plain JavaScript and CSS.\n    - `.coffee` - Compile CoffeeScript into JavaScript\n    - `.ejs` - Run a file through EJS (e.g. to populate configuration parameters into a JavaScript file)\n    - `.less` - Compile Less into CSS\n    - `.hbs` - Precompile Handlebars templates into JavaScript files that register them with `Handlebars.templates`.\n    - `.dust` - Precompile Dust templates into JavaScript files that register them for use with `dust.render`.\n    - Processors can be chained together.  E.g `test.js.hbs.ejs` (run Handlebars template through EJS, then compile it)\n    - Additional processors can be plugged in.\n- Merging files together using Manifest files (`.mf`) with dependency management directives similar to Sprockets.\n    - `require` - Require a single file\n    - `require_dir` - Require all the files in a specific directory\n    - `require_tree` - Require all the files in a specific directory (and subdirectories)\n- Compressing, gzipping, and generating hashed file names.\n    - Compress JavaScript files with `uglify-js`\n    - Compress LESS during LESS preprocessing\n    - Generate Gzipped versions of files\n    - Include a MD5 hash of the file's contents in the file name. `myAsset.js` -> `myAsset-c89cba7b7df028e65cb01d86f4d27077.js`\n        - `asset_path` helper that can be used to reference the hashed name.\n\nIt's released under the [MIT](http://en.wikipedia.org/wiki/MIT_License) license.\n\n## <a name=\"structure-assets\"></a> Structuring Your Assets\n\nAsset Smasher has the concept of \"asset paths\".  These are locations in which your asset files will be located, and from which any relative asset paths will be rooted to.\n\nThe simplest structure has one asset path.\n\nE.g.\n\n    Asset Paths\n    -----------\n     - app\n\n    File Structure\n    --------------\n    app/\n      js/\n      css/\n      images/\n\nA more complicated structure might be\n\n    Asset Paths\n    -----------\n     - app\n     - lib\n     - vendor\n\n    File Structure\n    --------------\n    app/\n      js/\n      css/\n      images/\n    lib/\n      js/\n      css/\n      images/\n    vendor/\n      js/\n      css/\n      images/\n\nBoth of these examples will result in a compiled structure of\n\n    js/\n    css/\n    images/\n\n### <a name=\"manifest-files\"></a> Manifest Files\n\nManifest (`.mf`) files are used to merge many assets into a single resulting file. The file should be named with the resulting file type before the `.mf` extension (e.g. `manifest.css.mf` or `manifest.js.mf`. *Manifest files can `require` other manifest files*\n\nA simple manifest file might look like\n\n    # A comment here\n    require \"./one.js\"\n    require_dir \"./subdir1\"\n    #\n    # Another comment\n    require_tree \"./subdir2\"\n\n**Directives:**\n\n<table border=\"1\" cellpadding=\"5\" cellspacing=\"0\" width=\"100%\">\n <thead>\n  <tr><th width=\"15%\">Directive</th><th width=\"85%\">Description</th></tr>\n </thead>\n <tbody>\n  <tr>\n    <td><code>require \"[path]\"</code></td>\n    <td>\n      <strong>Include a single file</strong>\n      <ul>\n       <li>\n         If the path starts with <code>\"/\"</code>, <code>\"../\"</code>, or <code>\"./\"</code>, process and include the specified file.  The file <em>must</em> be\n         inside one of the configured asset paths.\n       </li>\n       <li>\n         If the path does not start with <code>\"/\"</code>, <code>\"../\"</code>, or <code>\"./\"</code>, the file will be searched for in all of the configured\n         asset paths.  E.g. if there are asset paths <code>one</code> and <code>two</code> defined, <code>require \"js/test.js\"</code>\n         will look for <code>one/js/test.js</code> and then <code>two/js/test.js</code> stopping when it finds a matching file.\n       </li>\n       <li>\n         The filename part of the path does not have to include the whole extension.  E.g <code>require \"test\"</code>\n         finds the first file that matches the name in the asset paths (for example <code>test.js.ejs</code>)\n       </li>\n      </ul>\n    </td>\n  </tr>\n  <tr>\n    <td><code>require_dir \"[path]\"</code></td>\n    <td>\n      <strong>Include all the files in a directory</strong>\n      <ul>\n       <li>\n         The path must be absolute, or relative to the current directory.  E.g. you can do <code>require_dir \"../some/other/dir\"</code>\n         but not <code>require_dir \"somedir\"</code>\n       </li>\n       <li>\n         If using absolute paths, or <code>\"..\"</code> in your paths, the resulting directory needs to be inside one of the configured asset paths.\n       </li>\n       <li>\n         Make sure the directory only contains assets of the type you want.  E.g. for <code>myManifest.js.mf</code>, the dir required had better\n         only contain javascript files, or else bad things will happen.\n       </li>\n      </ul>\n    </td>\n  </tr>\n  <tr>\n    <td><code>require_tree \"[path]\"</code></td>\n    <td>\n      <strong>Include the files in a directory recursively</strong>\n      <ul>\n        <li>The rules for <code>require_tree</code> are the same as the rules for <code>require_dir</code></li>\n      </ul>\n    </td>\n  </tr>\n </tbody>\n</table>\n\n## <a name=\"command-line\"></a> Using via Command-Line\n\nUse `npm install -g asset-smasher` to install the `asset-smasher` command-line tool globally.\n\n      asset-smasher --help\n\n        Usage: asset-smasher [options] <output dir>\n\n        Options:\n\n          -h, --help               output usage information\n          -V, --version            output the version number\n          --compress               compress/minify the generated files\n          --hash                   generate versions of the files with md5 hashes in the name\n          --gzip                   generate gzipped versions of the compiled files\n          --hashVersion <version>  invalidate all assets without changing file contents [1.0]\n          --only <pattern,...>     only process the files matching these glob patterns (relative to any of the paths) [**/*]\n          --paths <path,...>       list of paths to look for assets [.]\n          --prefix <prefix>        prefix to append to logical paths when constructing urls. use if output dir is not served from the root of your web app []\n          --helpers <js_file>      a .js module of helper functions require()s to expose to transforms []\n          --plugins <js_file>      a .js plugin module []\n\n        If --only is not specified, *all* files in the --paths will be processed.\n\n        Examples:\n\n          Compile all assets in the current directory to /home/me/compiledAssets\n\n            $ asset-smasher /home/me/compiledAssets\n\n          Something similar to what the Rails asset pipeline does by default\n\n            $ asset-smasher --compress --hash --gzip --prefix=/assets \\\n                --paths=./js,./css,./images \\\n                --only **/*.{jpg,gif,png},application.js.mf,application.css.mf ./public/assets\n\n          Compile assets, providing some custom helpers to the transformation\n\n            $ asset-smasher --helpers helpers.js output\n\n### <a name=\"cli-helpers\"></a> Helpers\n\nThere is a built-in `asset_path` helper that can be used to get the \"real\" (i.e. with hashed file name) path of an asset.  E.g. `asset_path('css/myFile.css')` might return `'/assets/css/myFile-c89cba7b7df028e65cb01d86f4d27077.css`.\n\nSome transformers (e.g. the `.ejs` one) take in a set of local variables that they can use during transformation. You can pass in the path to a JavaScript module whose exports will be included in this set of variables.\n\nYou can use this, for example, to set configuration parameters in your JS files:\n\n**helper.js**\n\n    exports.serviceUrl = 'http://my.service/';\n\n**config.js.ejs**\n\n    //...\n    var serviceUrl = '<%= serviceUrl %>';\n    var cssLocation = '<%= asset_path('css/myFile.css') %>';\n    //...\n\n**Execution**\n\n    $ asset-smasher --helpers helper.js --only config.js.ejs,css/myFile.css .\n    $ cat config.js\n    var serviceUrl = 'http://my.service/';\n    var cssLocation = '/assets/css/myFile-c89cba7b7df028e65cb01d86f4d27077.css';\n\n\n### <a name=\"cli-plugins\"></a> Plugins\n\nIf there's a type of file you want to pre-process that is not natively supported by Asset Smasher, you can add it using a plugin file.\n\n*TODO: How to add additional transformers via a plugin file.*\n\n## <a name=\"express-middleware\"></a> Using via Express Middleware\n\nAsset smasher exposes an `express` middleware that can:\n\n- Serve your assets un-merged/mangled in development mode.\n- Serve precompiled assets (with hashed file names) in production mode.\n\nThe middleware takes in the same arguments as the `Smasher` constructor, with a few extras:\n\n- `serve` - boolean whether the middleware should serve the asset files.  Usualy set this to `true` in development, `false` in production\n- `assetMapLocation` - path to the `map.json` generated by the command-line `asset-smasher` util.  This allows the helper methods to determine what the hashed file names were\n\nThe middleware exposes two helpers to your views:\n\n- `js_asset(logicalPath)` - Render a `<script>` tag for the specified JS asset. When `serve` is true, this will \"explode\" manifests and write out a separate `<script>` for each required file.  This makes debugging much easier.\n- `css_asset(logicalPath)` - Render a `<link>` tag for the specified CSS asset.  Same thing happens when `serve` is true.\n\n### Example\n\n    var assetSmasher = require('asset-smasher');\n\n**Middleware config (Dev)**\n\n    app.use(assetSmasher.middleware({\n      serve: true,\n      paths: [path.join(__dirname, 'assetDir1'), path.join(__dirname, 'assetDir2')],\n      prefix: '/assets',\n      outputTo: path.join(__dirname, 'tmp')\n    }));\n\n**Middleware config (Prod)**\n\n    app.use(assetSmasher.middleware({\n      serve: false,\n      prefix: '/assets',\n      assetMapLocation: path.join(__dirname, 'public/assets/map.json')\n    }));\n\n**View (ejs here, but could be others)**\n\n    <!DOCTYPE html>\n    <html>\n    <head>\n      <title>Test</title>\n      <%- css_asset('application.css') %>\n      <%- js_asset('application.js') %>\n    </head>\n    <body>\n      This is a test\n    </body>\n    </html>\n\n## <a name=\"programmatic-interface\"></a> Using via Programmatic Interface\n\nYou can invoke Asset Smasher programmatically by `require`ing it.  You can also plug in additional transformers this way.\n\nThe `Smasher` object has the following methods:\n\n - `compileAssets(cb)` - Find and compile all the assets.\n - `compileSingleAsset(assetFilePath, cb)` - Compile a single asset (assetFilePath is the actual path to the file, not a logical path)\n - `findAssets(cb)` - Find, but don't compile the assets.  Good for determining dependency graph without compiling.\n - `getAssetByLogicalPath(logicalPath)` - Get information about an asset by its logical path.  Only call this after finding/compiling assets.\n - `getHashedFileMapping()` - When `hash` is true, this returns a mapping of logical path to \"hashed\" logical path.  This object is what the command-line tool outputs to `map.json`. Only call this after finding/compiling assets.\n - `getRequiredLogicalPathsFor(asset)` - Get the logical paths of the assets that should be merged into the specified asset (populated for `.mf` files). Only call this after finding/compiling assets.\n - `getProcessingOrderLogicalPaths()` - Get a list of the order in which assets should be processed in order to satisfy all dependencies. Only call this after finding/compiling assets.\n\nThe `Asset` object returned by `getAssetByLogicalPath` has the following properties:\n - `logicalPath` - The logical path\n - `hashedPath` - If `hash` is true, the hashed filename path, otherwise the same as `logicalPath`\n - `assetFilePath` - The full path to the actual source asset\n - `compiled` - Whether the asset has been compiled\n - `compiledAssetFilePath` - The full path to the compiled asset file\n\n**Example**\n\n    var assetSmasher = require('asset-smasher');\n    var Smasher = assetSmasher.Smasher;\n\n    // Plug in a custom transformer\n    assetSmasher.transforms['MyAwesomeFormat'] = require('myAwesomeFormatTransformer');\n\n    var sm = new Smasher({\n      paths:['/path/one', '/path/two'],\n      only:['**/*.{jpg,gif,png}', 'application.js.mf', 'application.css.mf'],\n      prefix:'/assets',\n      compress:true,\n      hash:true,\n      hashVersion:'1.0',\n      gzip:true,\n      outputTo:__dirname + '/public/assets',\n      helpers:{\n       my: 'helper',\n       another: 'helper'\n      }\n    });\n    sm.compileAssets(function(err) {\n      if(err) {\n        console.log('An error occurred', err);\n      } else {\n        console.log('Compilation done!');\n      }\n    });\n\n## <a name=\"transformer-notes\"></a> Transformer Notes\n\n### <a name=\"tn-less\"></a> LESS\n\n- When the `compress` option is true, the compression is done directly via the `less` compiler\n- Any `@include` paths are *relative to the path that the file is in*.\n- Any `@include`d files will *not* be processed individually by Asset Smasher (i.e. you can't `@include` a LESS file that is preprocessed by ejs)\n\n### <a name=\"tn-ejs\"></a> ejs\n\n- Any registered helpers will be exposed as global variables to the `ejs` transform.\n- The built-in `asset_paths` helper can be used here.\n\n### <a name=\"tn-dust-hbs\"></a> dust and Handlebars\n\n- The name of the template will be the template's \"logical path\" (minus the asset path it is in), minus the `.js.dust` or `.js.hbs` file extension.\n    - E.g. `/my/templates/test.js.dust`'s template name will be `test` (assuming `/my/templates` is the asset path)\n","maintainers":[{"name":"jriecken","email":"jriecken@gmail.com"}],"time":{"modified":"2022-06-13T03:34:12.720Z","created":"2012-06-11T22:49:29.267Z","0.1.0":"2012-06-11T22:49:31.423Z","0.1.1":"2012-06-12T21:17:18.023Z","0.1.2":"2012-06-27T18:45:07.706Z","0.1.3":"2012-06-28T15:15:24.432Z","0.1.4":"2012-07-05T20:18:19.904Z","0.2.0":"2012-08-16T03:44:44.501Z","0.2.1":"2012-09-17T18:19:42.329Z","0.2.2":"2012-11-07T17:23:45.805Z","0.2.3":"2013-03-15T06:11:28.334Z","0.2.4":"2013-03-17T01:12:17.745Z","0.2.5":"2013-03-19T05:53:25.202Z","0.2.6":"2013-04-17T21:05:09.992Z","0.2.7":"2013-04-17T21:27:23.823Z","0.2.8":"2013-04-29T04:28:04.457Z","0.2.9":"2013-04-30T03:36:13.610Z","0.2.10":"2013-05-01T01:05:30.745Z","0.2.11":"2013-05-18T18:02:05.985Z","0.2.12":"2013-05-31T03:42:06.361Z","0.3.0":"2013-06-02T01:28:25.885Z","0.3.1":"2013-06-21T02:17:59.406Z","0.3.2":"2013-06-21T04:18:10.858Z"},"author":{"name":"Jim Riecken","email":"jriecken@gmail.com"},"repository":{"type":"git","url":"git://github.com/jriecken/asset-smasher.git"}}