asset-smasher
Advanced tools
Comparing version 0.1.4 to 0.2.0
# Asset Smasher Changelog | ||
## 0.2.0 (August 15, 2012) | ||
- Add a transformer for Stylus `.styl` files (Fixes #2) | ||
- Document how to plug in additional transformers. | ||
## 0.1.4 (July 5, 2012) | ||
@@ -4,0 +9,0 @@ |
@@ -23,2 +23,3 @@ /** | ||
Less:require('./transforms/less_transform'), | ||
Stylus:require('./transforms/stylus_transform'), | ||
Mf:require('./transforms/mf_transform') | ||
@@ -25,0 +26,0 @@ }; |
{ | ||
"name": "asset-smasher", | ||
"description": "Asset pre-processor, merger, and compressor.", | ||
"version": "0.1.4", | ||
"version": "0.2.0", | ||
"author": "Jim Riecken <jriecken@gmail.com>", | ||
@@ -6,0 +6,0 @@ "keywords": [ |
@@ -13,3 +13,3 @@ # Asset Smasher | ||
- [Transformer Notes](#transformer-notes) | ||
- [LESS](#tn-less) | ||
- [LESS/Stylus](#tn-less-styl) | ||
- [ejs](#tn-ejs) | ||
@@ -26,2 +26,3 @@ - [dust and Handlebars](#tn-dust-hbs) | ||
- `.less` - Compile Less into CSS | ||
- `.styl` - Compile Stylus into CSS | ||
- `.hbs` - Precompile Handlebars templates into JavaScript files that register them with `Handlebars.templates`. | ||
@@ -196,4 +197,4 @@ - `.dust` - Precompile Dust templates into JavaScript files that register them for use with `dust.render`. | ||
$ asset-smasher --compress --hash --gzip --prefix=/assets \ | ||
--paths=./js,./css,./images \ | ||
$ asset-smasher --compress --hash --gzip --prefix /assets \ | ||
--paths ./js,./css,./images \ | ||
--only **/*.{jpg,gif,png},application.js.mf,application.css.mf ./public/assets | ||
@@ -236,4 +237,46 @@ | ||
*TODO: How to add additional transformers via a plugin file.* | ||
For an example of what the transformer classes look like, look in the `lib/compilation/transforms` directory | ||
If 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`) | ||
To register your transformer, just add another entry to the `transforms` object. | ||
E.g. | ||
**my_plugin.js** | ||
module.exports = function(assetSmasher) { | ||
// A stupid transformer that adds "foo" to the start and end of the contents | ||
var FooTransform = function FooTransform(options) { | ||
this.options = options || {}; | ||
}; | ||
FooTransform.prototype = { | ||
extensions:function () { | ||
return ['.foo']; | ||
}, | ||
shouldTransform:function (file) { | ||
return path.extname(file) === '.foo'; | ||
}, | ||
transformedFileName:function (file) { | ||
return path.basename(file, '.foo'); | ||
}, | ||
transform:function (asset, cb) { | ||
// Transform the file name | ||
asset.logicalName = this.transformedFileName(asset.logicalName); | ||
// Get the contents | ||
var contents = asset.contents; | ||
if (Buffer.isBuffer(contents)) { | ||
contents = contents.toString('utf-8'); | ||
} | ||
// Compile the contents | ||
asset.contents = 'foo-' + contents + '-foo'; | ||
cb(); | ||
} | ||
}; | ||
assetSmasher.transforms.Foo = FooTransform; | ||
}; | ||
If you then invoke `asset-smasher` with `--plugins my_plugin.js` it will automatically transform `*.foo` files. | ||
## <a name="express-middleware"></a> Using via Express Middleware | ||
@@ -348,7 +391,7 @@ | ||
### <a name="tn-less"></a> LESS | ||
### <a name="tn-less-styl"></a> LESS/Styles | ||
- When the `compress` option is true, the compression is done directly via the `less` compiler | ||
- Any `@include` paths are *relative to the path that the file is in*. | ||
- 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) | ||
- When the `compress` option is true, the compression is done directly via the `less/stylus` compilers | ||
- Any `@include/@import` paths are *relative to the path that the file is in*. | ||
- 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) | ||
@@ -355,0 +398,0 @@ ### <a name="tn-ejs"></a> ejs |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Non-existent author
Supply chain riskThe package was published by an npm account that no longer exists.
Found 1 instance in 1 package
75830
24
1797
402
0