You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository has been archived by the owner on Jun 15, 2023. It is now read-only.
I am writing a brunch plugin which is transforming static files using handlebars and handlebars-layouts.
The plugin is picking up helpers (partials) from files on the filesystem - these are common layout files. They are then used across transforms of all the static files.
I want it to work in "watch" mode. So when a file is deleted, I want to unregister the partials that it corresponds to. Is there a hook for a plugin to be notified when a file is deleted? I've scoured the code but it seems impossible.
Thanks for your help!
The text was updated successfully, but these errors were encountered:
Hey @mr-miles, we appreciate the issue. I am on a mission to make Brunch fit more use cases without additional bloat and make it work predictably even on edge cases.
If partials depend on some asset, they can return it's path in dependencies, so they will be recompiled when the file gets removed.
Thanks for the reply. I have it returning the dependencies, and that works nicely - but it doesn't cover this case. Hopefully I can be a bit clearer:
when brunch sends the plugin a partial to compile, the partial is compiled and also registered with handlebars
then when static assets are compiled, they can reference the partial
but if the partial is deleted, there's no hook to find out about it and unregister the partial.
this means that assets that used to depend on the partial will still compile ok, even though that partial is no longer there on the file system. the correct behaviour is that they generate errors about missing dependencies.
Maybe I'm not doing this in a very brunch-y way - I'd appreciate any ideas? The alternative would be to find the dependencies of each static asset, and then compile and register all the dependencies each time. That's a bit tedious because then I need to examine each dependency for further dependencies etc, etc.
Also, in order to guarantee the partials are registered before any static assets are compiled, I register them all in a pre-compile step the first time round. Is there a better way for a plugin to say it wants to process certain paths first? Or is it expected to queue everything up via promises within the plugin?
I am writing a brunch plugin which is transforming static files using handlebars and handlebars-layouts.
The plugin is picking up helpers (partials) from files on the filesystem - these are common layout files. They are then used across transforms of all the static files.
I want it to work in "watch" mode. So when a file is deleted, I want to unregister the partials that it corresponds to. Is there a hook for a plugin to be notified when a file is deleted? I've scoured the code but it seems impossible.
Thanks for your help!
The text was updated successfully, but these errors were encountered: