Skip to content
This repository has been archived by the owner on Dec 9, 2024. It is now read-only.

Commit

Permalink
Log server info on JS or CSS change/reload
Browse files Browse the repository at this point in the history
  • Loading branch information
zarathustra323 committed Feb 20, 2023
1 parent 64ed3be commit 2ecd5f6
Showing 1 changed file with 9 additions and 3 deletions.
12 changes: 9 additions & 3 deletions packages/web-cli/serve/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ const ForkServer = require('./fork-server');
const build = require('../build');
const watchFiles = require('./watch');
const createLivereload = require('./create-livereload');
const formatWebsiteInfo = require('./format-website-info');
const formatServerMessage = require('./format-website-info');

module.exports = async ({
cwd,
Expand All @@ -21,13 +21,18 @@ module.exports = async ({
if (forceRequirePrebuiltTemplates) process.env.MARKO_REQUIRE_PREBUILT_TEMPLATES = true;
const livereload = createLivereload();

let serverInfo;

await build({
cwd,
entries,
compileDirs,
cleanCompiledFiles,
watch: true,
onFileChange: () => livereload.refresh('/'),
onFileChange: () => {
if (serverInfo) log(serverInfo);
livereload.refresh('/');
},
});

// fork and start the server instance
Expand All @@ -39,6 +44,7 @@ module.exports = async ({
onReady: () => livereload.refresh('/'),
});
const message = await server.listen({ rejectOnNonZeroExit: abortOnInstanceError });
serverInfo = formatServerMessage(message);
log(`server fork started in ${getProfileMS(serverStart)}ms`);

// enable file watching
Expand All @@ -51,5 +57,5 @@ module.exports = async ({
ignore: watchIgnore,
});
log(`done in ${getProfileMS(start)}ms`);
log(formatWebsiteInfo(message));
log(serverInfo);
};

0 comments on commit 2ecd5f6

Please sign in to comment.