marp-cli icon indicating copy to clipboard operation
marp-cli copied to clipboard

Watch mode doesn't watch all files

Open joenye opened this issue 5 years ago • 7 comments

It seems only changes to *.md files will be watched. For example, changes to images will not be watched.

Steps to reproduce

  1. Create a simple index.md that references image.png on a slide.
  2. Execute marp -psw .
  3. Change index.md -> Preview updates :ballot_box_with_check:
  4. Change image.png -> Preview does not update :negative_squared_cross_mark:

joenye avatar Sep 20 '20 16:09 joenye

Currently Marp CLI is observing the change only for Markdown file and theme CSS file because watching image resources using in Markdown requires extra parse step.

I think it's hard to implement, but also must have a worth.

yhatt avatar Sep 20 '20 16:09 yhatt

Thanks for the quick response.

I see you're already using chokidar. One should be able to watch all files in the user-provided directory with this.

In the simplest case, one could reload the build/preview every time any file in that directory changes.

In the more sophisticated case, one could determine which files are referenced by *.md files and only reload when they change.

joenye avatar Sep 20 '20 17:09 joenye

Yes. Probably we will take the simplest one at the first: should observe all files in specified directory by --input-dir / -I option.

In server mode, we are internally being inherited the passed directory to --input-dir option, so observer still will work in the server directory.

The fact we should consider is that the current watch mode can work in both of regular file conversion and server mode. When observer is working in regular conversion mode and the converted file was created into observed directory, we must avoid infinite loop.

yhatt avatar Sep 20 '20 17:09 yhatt

this would be a really helpful feature

simoneggler avatar Oct 27 '22 07:10 simoneggler