jalla
![js-standard-style](https://img.shields.io/badge/code%20style-standard-brightgreen.svg?style=flat-square)
Jalla is an opinionated web compiler and server in one, intended for both development and production use. Jalla puts together popular tools and frameworks that makes web development fun and performant.
The stack consists of a Koa server, a Browserify bundler for scripts and PostCSS for styles. Documents are compiled using documentify. It's intended for use with Choo and heavily inspired by Bankai. In fact, if static bundling and CSS in JS is your thing, you'll probably have a better time using Bankai.
Usage
$ jalla index.js
API
Middleware can be added by creating an instance of the server. The application is an instance of Koa and supports all Koa middleware.
var jalla = require('jalla')
var app = jalla('index.js')
app.use(require('koa-compress')())
app.use(function (ctx, next) {
if (ctx.path === '/robots.txt' && process.env.NODE_ENV !== 'production') {
ctx.type = 'text/plain'
ctx.body = `
User-agent: *
Disallow: /
`
}
return next()
})
app.listen(8080)
Events
Most of the internal workings are exposed as events on the application (Koa) instance.
app.on('error', callback(err))
When an internal error occurs or a route could not be served. If an HTTP error was encountered, the status code is availible on the error object.
app.on('warning', callback(warning))
When a non-critical error was encountered, e.g. a postcss plugin failed to parse a rule.
app.on('progress', callback(file))
When a change is detected to an entry file and processing begins.
app.on('bundle:script', callback(file, buff)
When a script file finishes bundling.
app.on('bundle:style', callback(file, buff)
When a css file finishes bundling.
app.on('bundle:file', callback(file))
When a file is being included in a bundle.
app.on('timing', callback(time, ctx))
When a HTTP response has been sent.
app.on('start', callback(port))
When the server starts.
Todo