Skip to content

Commit

Permalink
disable livereload background image loading behavior (#1264)
Browse files Browse the repository at this point in the history
  • Loading branch information
thescientist13 authored Aug 21, 2024
1 parent 390d7a1 commit 38671e5
Showing 1 changed file with 12 additions and 9 deletions.
21 changes: 12 additions & 9 deletions packages/cli/src/plugins/server/plugin-livereload.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand All @@ -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);
}
}

Expand Down

0 comments on commit 38671e5

Please sign in to comment.