Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/grayleonard/koa-uglify2
Koa middleware to uglify javascript
https://github.com/grayleonard/koa-uglify2
Last synced: 13 days ago
JSON representation
Koa middleware to uglify javascript
- Host: GitHub
- URL: https://github.com/grayleonard/koa-uglify2
- Owner: grayleonard
- License: isc
- Created: 2014-11-15T03:18:30.000Z (about 10 years ago)
- Default Branch: master
- Last Pushed: 2014-11-18T22:38:21.000Z (about 10 years ago)
- Last Synced: 2024-11-18T15:01:38.954Z (25 days ago)
- Language: JavaScript
- Homepage: https://www.npmjs.org/package/koa-uglify2
- Size: 211 KB
- Stars: 0
- Watchers: 3
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
- awesome-koa - koa-uglify2 - 带有缓存的 js 的uglify中间件。 ![](https://img.shields.io/github/stars/grayleonard/koa-uglify2.svg?style=social&label=Star) ![](https://img.shields.io/npm/dm/koa-uglify2.svg?style=flat-square) (仓库 / 中间件)
README
koa-uglify2
===========Koa middleware to uglify javascript.
Inspired by [express-uglify](https://github.com/ncrohn/express-uglify)It automatically uglifies every javascript file served. A basic cache functions to cut down on load time.
Install
=======```
npm install koa-uglify2
```Basic Usage
===========```javascript
var koa = require('koa');
var app = koa();
var uglify = require('koa-uglify2');app.use(uglify({
src: 'public/'
})
);app.listen(8080);
```Advanced Usage
==============You can also create regex rules to uglify files that are not served statically.
```javascript
app.use(uglify({
src: 'public/',
rules: {
'google/jquery.js': /^\/.{3}\/regexExample\.js$/
}
})
);
```This rule will serve public/google/jquery.js to any request that matches the regex, for example: ```GET /123/regexExample.js```. File-level regex needs to end with ```\.js$/```.
As well, you can designate a directory-level rule to match all javascript files in the folder.
```javascript
app.use(uglify({
rules: {
'admin-files/': /^\/.{5}\//
}
})
);
```This rule will serve admin-files/*.js to, for example: ```GET /12345/testFile.js```