var Koa = require('koa')
var mount = require('koa-mount')
var watch = require('koa-postcss-watch')
var app = new Koa()
if (process.env.NODE_ENV === 'development') {
  app.use(mount('/bundle.css', watch({
    file: 'lib/index.css',
    plugins: [require('postcss-import'), require('autoprefixer')]
  })))
}
app.use(function (ctx) {
  ctx.body = `
    <!doctype html>
    <html>
    <head>
      <meta charset="utf-8">
      <link rel="stylesheet" href="/bundle.css">
    </head>
    <body>
      Hello world
    </body>
    </html>
  `
})
app.listen(process.env.PORT)Create a middleware function. If opts.file is not defined, path to file will be resolved to ctx.path relative to opts.root or process.cwd().
Options are forwarded to both chokidar and postcss.
- file <string>CSS entry file
- root <string>Path from which to resolve file paths (defaults to cwd)
- plugins [<string>]List of plugins to use with postcss
$ npm install -S koa-postcss-watchMIT