koa-files-combiner

1.1.1 • Public • Published

koa-files-combiner

A koa middleware for combining files.

Usage

var koa = require('koa')
var combine = require('koa-files-combiner')
 
var app = koa()
app.use(combine('path/to/static/files/root'))
 
app.listen(3000)

Then request the files bundle in browser:

http://localhost:3000/combine/js/global/libs.min.js,/bootstrap/bootstrap.min.js
                     /-------/--/------------------,/--------------------------
                        |     |         file1                 file2
                        |     |
                        |    type("js" or "css", for MIME)
                        |
                      use combine service

Options

app.use(combine('path/to/static/files/root', options))

which options could be:

{
  prePathParser: function(url) { /*...*/ return url },
  pathParser: function(url) { /*...*/ return filesObj },
  postPathParser: function(filesObj) { /*...*/ return filesObj }
}

the filesObj should be:

{
  type: 'js',
  files: ['path/to/file1.js', 'path/to/file2.js']
}

Versions

Current Tags

  • Version
    Downloads (Last 7 Days)
    • Tag
  • 1.1.1
    0
    • latest

Version History

Package Sidebar

Install

npm i koa-files-combiner

Weekly Downloads

0

Version

1.1.1

License

ISC

Last publish

Collaborators

  • amio