From a1ce0bc84272845430c141828a2fe8f92ccfa561 Mon Sep 17 00:00:00 2001 From: Owen Buckley Date: Fri, 9 Aug 2024 18:37:20 -0400 Subject: [PATCH] disable livereload background image loading behavior --- .../src/plugins/server/plugin-livereload.js | 21 +++++++++++-------- 1 file changed, 12 insertions(+), 9 deletions(-) diff --git a/packages/cli/src/plugins/server/plugin-livereload.js b/packages/cli/src/plugins/server/plugin-livereload.js index e3303e616..af371bfd4 100644 --- a/packages/cli/src/plugins/server/plugin-livereload.js +++ b/packages/cli/src/plugins/server/plugin-livereload.js @@ -9,7 +9,7 @@ class LiveReloadServer extends ServerInterface { } async start() { - const { userWorkspace } = this.compilation.context; + const { userWorkspace, projectDirectory } = this.compilation.context; const standardPluginsDirectoryPath = new URL('../resource/', import.meta.url); const standardPluginsNames = (await fs.readdir(standardPluginsDirectoryPath)) .filter(filename => filename.indexOf('plugin-standard') === 0); @@ -34,18 +34,21 @@ class LiveReloadServer extends ServerInterface { ...customPluginsExtensions, ...this.compilation.config.devServer.extensions ] - .filter((ext) => ext !== '*' || ext !== '') - .map((ext) => ext.replace('.', '')); + .filter((ext) => ext !== '*' || ext !== '') // basic filter for false positives + .filter((ext, idx, array) => array.indexOf(ext) === idx) // dedupe + .map((ext) => ext.startsWith('.') ? ext.replace('.', '') : ext); // trim . from all entries const liveReloadServer = livereload.createServer({ - exts: allExtensions.filter((ext, idx) => idx === allExtensions.indexOf(ext)), - applyCSSLive: false // https://github.com/napcs/node-livereload/issues/33#issuecomment-693707006 - }); + exts: allExtensions, + applyCSSLive: false, // https://github.com/napcs/node-livereload/issues/33#issuecomment-693707006 + applyImgLive: false // https://github.com/ProjectEvergreen/greenwood/issues/1263 + }, () => { + const abridgedWorkspacePath = userWorkspace.pathname.replace(projectDirectory.pathname, '').replace('/', ''); - liveReloadServer.watch(userWorkspace.pathname, () => { - console.info(`Now watching directory "${userWorkspace}" for changes.`); - return Promise.resolve(true); + console.info(`Now watching workspace directory (./${abridgedWorkspacePath}) for changes...`); }); + + liveReloadServer.watch(userWorkspace.pathname); } }