mirror of
https://github.com/kevin-DL/sapper.git
synced 2026-01-14 03:54:46 +00:00
require chokidar lazily; dev-mode only
This commit is contained in:
@@ -1,5 +1,4 @@
|
||||
const glob = require('glob');
|
||||
const chokidar = require('chokidar');
|
||||
const create_routes = require('./utils/create_routes.js');
|
||||
const { src, dev } = require('./config.js');
|
||||
|
||||
@@ -20,7 +19,7 @@ function update() {
|
||||
update();
|
||||
|
||||
if (dev) {
|
||||
const watcher = chokidar.watch(`${src}/**/*.+(html|js|mjs)`, {
|
||||
const watcher = require('chokidar').watch(`${src}/**/*.+(html|js|mjs)`, {
|
||||
ignoreInitial: true,
|
||||
persistent: false
|
||||
});
|
||||
@@ -28,4 +27,4 @@ if (dev) {
|
||||
watcher.on('add', update);
|
||||
watcher.on('change', update);
|
||||
watcher.on('unlink', update);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
const fs = require('fs');
|
||||
const glob = require('glob');
|
||||
const chokidar = require('chokidar');
|
||||
const { dev } = require('./config.js');
|
||||
|
||||
let templates;
|
||||
@@ -65,7 +64,7 @@ function create_templates() {
|
||||
create_templates();
|
||||
|
||||
if (dev) {
|
||||
const watcher = chokidar.watch('templates/**.html', {
|
||||
const watcher = require('chokidar').watch('templates/**.html', {
|
||||
ignoreInitial: true,
|
||||
persistent: false
|
||||
});
|
||||
@@ -87,4 +86,4 @@ exports.stream = (res, status, data) => {
|
||||
if (template) return template.stream(res, data);
|
||||
|
||||
return `Missing template for status code ${status}`;
|
||||
};
|
||||
};
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
const fs = require('fs');
|
||||
const path = require('path');
|
||||
const chokidar = require('chokidar');
|
||||
const route_manager = require('../route_manager.js');
|
||||
const { src, entry, dev } = require('../config.js');
|
||||
|
||||
@@ -70,7 +69,7 @@ function create_app() {
|
||||
if (dev) {
|
||||
route_manager.onchange(create_app);
|
||||
|
||||
const watcher = chokidar.watch(`templates/main.js`, {
|
||||
const watcher = require('chokidar').watch(`templates/main.js`, {
|
||||
ignoreInitial: true,
|
||||
persistent: false
|
||||
});
|
||||
@@ -80,4 +79,4 @@ if (dev) {
|
||||
watcher.on('unlink', create_app);
|
||||
}
|
||||
|
||||
module.exports = create_app;
|
||||
module.exports = create_app;
|
||||
|
||||
Reference in New Issue
Block a user