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

Commit

Permalink
Merge pull request #590 from zarathustra323/4.x_log-on-change
Browse files Browse the repository at this point in the history
Log server info on JS/CSS reload
  • Loading branch information
zarathustra323 authored Feb 20, 2023

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature.
2 parents 64ed3be + 2ecd5f6 commit d1f6323
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
@@ -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,
@@ -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
@@ -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
@@ -51,5 +57,5 @@ module.exports = async ({
ignore: watchIgnore,
});
log(`done in ${getProfileMS(start)}ms`);
log(formatWebsiteInfo(message));
log(serverInfo);
};

0 comments on commit d1f6323

Please sign in to comment.