@stackpress/ink-dev
v0.3.11
Published
Ink developer mode with hot page reload
Downloads
597
Readme
💧 Ink DEV
This package is designed for Ink, the reactive web component template engine. See docs for more information.
Ink developer mode with hot page reload. Not suited for production environments.
Install
$ npm -i @stackpress/ink-dev
Usage
import http from 'http';
import ink from '@stackpress/ink/compiler';
import { dev } from '@stackpress/ink-dev';
//create ink compiler
const compiler = ink({ cwd: __dirname });
//1. create dev tools
const { router, refresh } = dev({ cwd: __dirname });
//create http server
const server = http.createServer(async (req, res) => {
//2. Add dev router
if (router(req, res)) return;
//if home page
if (req.url === '/') {
//3. sync builder with refresh server
refresh.sync(compiler.fromSource('./page.ink'));
//compile the document
const html = await compiler.render('./page.ink');
//... send response ...
}
//... other routes ...
});
//listen on port 3000
server.listen(3000);