# @hypha/web-compiler @hypha/web-compiler v1.0.0 was forked from Bankai v9.15.0. [Bankai](https://github.com/choojs/bankai) is an excellent “friendly web compiler” by [Yoshua Wuyts](https://github.com/yoshuawuyts), [Renée Kooi](https://github.com/goto-bus-stop), and [other contributors](https://github.com/choojs/bankai/graphs/contributors). If you want a general purpose web compiler, please use Bankai and [back their project](https://opencollective.com/choo). @hypha/web-compiler is a simplified version of Bankai, tuned for the needs of the Hypha project that uses [https-server](https://source.ind.ie/hypha/tools/https-server) for seamless installation and use of locally-trusted certificates during development (and, soon, seamless Let’s Encrypt certificate provisioning and use in production). ## Installation ```sh npm i @hypha/web-compiler ``` ## Usage The primary use case of web-compiler is programmatically with Hypha. In Hypha, web-compiler is used: 1. As a live build and reload tool on development. 2. As a build and optimisation tool on production. There is a command-line binary but it is not used in Hypha except for its _inspect_ command: ```sh web-compiler inspect ``` ## Example @hypha/web-compiler is used by hooking it up to an HTTPS server. The following example demonstrates how you can use @hypha/web-compiler in both development and production and alongside regular HTTPS and WebSocket routes (the latter demonstrated using the [Express](http://expressjs.com/) framework): ```js const httpsServer = require('@ind.ie/https-server') const express = require('express') const expressWebSocket = require('express-ws') const path = require('path') // Catch any uncaught errors. process.on('uncaughtException', function (error) { console.log('Uncaught exception:', error) }) // Create the Express app, the HTTPS server, and add WebSocket support. const app = express() const server = httpsServer.createServer({}, app) expressWebSocket(app, server, { perMessageDeflate: false }) // // Websocket routes go here. // app.ws('/echo', (webSocket, request) => { webSocket.on('message', message => { console.log('Got web socket request to echo ', message) webSocket.send(message) }) }) // // Regular HTTPS routes go here. // app.get('/hello', (request, response) => { response.writeHeader(200, {'Content-Type': 'text/html'}) response.end('Hello