Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/mekwall/node-resmin
All-in-one minifier/merger/compressor middleware for connect/express
https://github.com/mekwall/node-resmin
Last synced: 11 days ago
JSON representation
All-in-one minifier/merger/compressor middleware for connect/express
- Host: GitHub
- URL: https://github.com/mekwall/node-resmin
- Owner: mekwall
- License: mit
- Created: 2011-07-04T20:25:39.000Z (over 13 years ago)
- Default Branch: master
- Last Pushed: 2012-02-15T09:17:02.000Z (over 12 years ago)
- Last Synced: 2024-10-19T19:54:32.670Z (20 days ago)
- Language: JavaScript
- Homepage:
- Size: 117 KB
- Stars: 10
- Watchers: 2
- Forks: 1
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- Changelog: HISTORY.md
- License: LICENSE
Awesome Lists containing this project
README
# resmin
All-in-one minifier/merger/compiler/compressor middleware for connect/express.## Installation
```bash
$ npm install resmin
```## Dependencies
Resmin depends on the following libraries:
- [uglify-js](https://github.com/mishoo/UglifyJS)
- [uglifycss](https://github.com/fmarcia/UglifyCSS)
- [gzip-js](https://github.com/beatgammit/gzip-js)
- [mime](https://github.com/bentomas/node-mime)## Supported
Resmin has integrated support for the the following libraries:
- [stylus](http://learnboost.github.com/stylus/)
- [less](https://github.com/cloudhead/less.js)## Basic usage
Resmin is built to be dead simple to use and implement.
###Example configuration:
```javascript
var resminConfig = {
gzip: true,
merge: true,
minify: true,
js: {
"all": [
"//ajax.googleapis.com/ajax/libs/jquery/1.6.2/jquery.min.js",
"//ajax.googleapis.com/ajax/libs/jqueryui/1.8.14/jquery-ui.min.js",
"/js/foo.js",
"/js/bar.js",
"/js/baz.js"
]
},
css: {
"all": [
"//fonts.googleapis.com/css?family=Inconsolata:regular&v1",
"/css/foo.css",
"/css/bar.css",
"/css/baz.css"
]
}
};
```
Instantiate resmin and add the middleware and dynamic helper to connect/express.
var resmin = require('resmin');
app.use(resmin.middleware(express, __dirname+'/public/', resminConfig));
app.dynamicHelpers(resmin.dynamicHelper);The resmin variable is now accessible through your template engine of choice.
###Example when using jade/haml:
```yaml
- each url in resmin.css.all
link(rel='stylesheet', href=url)
- each url in resmin.js.all
script(src=url)
```###Example when using ejs:
```html
<% for (url in resmin.css.all) { %>
<% } %>
<% for (url in resmin.js.all) { %>
<% } %>
```###Example when using less:
Just add your .less files either to the css group. They will be
automatically parsed, compiled, merged and compressed according to your settings.```javascript
var resminConfig = {
...
css: {
"/css/foo.less",
"/css/bar.less",
"/css/baz.less"
}
}
```###Example when using stylus:
Just add your .less files either to the css group. They will be
automatically parsed, compiled, merged and compressed according to your settings.```javascript
var resminConfig = {
...
css: {
"/css/foo.styl",
"/css/bar.styl",
"/css/baz.styl"
},
stylus: function(style) {
// Add your own stylus settings
return style;
}
}
```## License
Copyright (c) 2011 Marcus Ekwall, http://writeless.se/
Permission is hereby granted, free of charge, to any person obtaining
a copy of this software and associated documentation files (the
"Software"), to deal in the Software without restriction, including
without limitation the rights to use, copy, modify, merge, publish,
distribute, sublicense, and/or sell copies of the Software, and to
permit persons to whom the Software is furnished to do so, subject to
the following conditions:The above copyright notice and this permission notice shall be
included in all copies or substantial portions of the Software.THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
## Additional creditsCredits and thanks to [tomgallacher](https://github.com/tomgallacher) for
[gzippo](https://github.com/tomgallacher/gzippo) and [bengourley](https://github.com/bengourley)
for [minj](https://github.com/bengourley/minj) which resmin is loosely based upon.