rebundle when routes and templates change

This commit is contained in:
Rich Harris
2017-12-20 17:34:23 -05:00
parent cd91bf2ca4
commit fefb0d96d7
9 changed files with 257 additions and 73 deletions

View File

@@ -1,5 +1,6 @@
const fs = require('fs');
const path = require('path');
const chokidar = require('chokidar');
const route_manager = require('../route_manager.js');
const { src, dest, server_routes, dev } = require('../config.js');
@@ -7,7 +8,7 @@ function posixify(file) {
return file.replace(/[\/\\]/g, '/');
}
module.exports = function create_app() {
function create_app() {
const { routes } = route_manager;
function create_client_main() {
@@ -64,7 +65,12 @@ module.exports = function create_app() {
fs.utimesSync(server_routes, new Date(atime.getTime() - 999999), new Date(mtime.getTime() - 999999));
}
// TODO in dev mode, watch files
create_client_main();
create_server_routes();
};
}
if (dev) {
route_manager.onchange(create_app);
}
module.exports = create_app;