Created
September 21, 2017 18:29
-
-
Save yoshuawuyts/962557eea0920d3321dabf56ab467ace to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var bankai = require('./') | |
var http = require('http') | |
var path = require('path') | |
var compiler = bankai(path.join(__dirname, 'example/index.js'), { watch: true }) | |
http.createServer(function (req, res) { | |
if (req.url === '/index.html' || req.url === '/') { | |
compiler.documents('index.html', function (err, node) { | |
if (err) throw err | |
res.end(node.buffer) | |
}) | |
} else if (/bundle\.js$/.test(req.url)) { | |
compiler.scripts('bundle.js', function (err, node) { | |
if (err) throw err | |
res.end(node.buffer) | |
}) | |
} else if (/bundle\.css$/.test(req.url)) { | |
compiler.style(function (err, node) { | |
if (err) throw err | |
res.end(node.buffer) | |
}) | |
} else { | |
res.writeHead(404) | |
res.end() | |
} | |
}).listen(8080, function () { | |
console.log('listening on port 8080') | |
}) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment