OFFLINE-GmbH / oc-vite-plugin

Vite integration for October CMS
MIT License
23 stars 9 forks source link

add support for child themes without their own assets #15

Closed marcogrueter closed 7 months ago

marcogrueter commented 7 months ago

We sometimes use a parent/child theme setup, where the child themes get the assets of the parent theme. This was not possible with the plugin so far.

The changes adds a check when extracting the outDir and getting manifest.json: does the current theme has a parent and does the target file/folder not exists in the current theme? then replace the theme path with the parent theme path.

I've tested this with our usual setup (build directory outside the published assets directory being the main thing) and with the standard configuration in the README, in vite dev mode and as vite build.

Not sure if this is the right way (e. g. it might be possible to refactor the getManifest method, skipping the file validation checks and let OCMS handle looking for the file in the parent theme), but I think this works well.

Let me know what you think!

Kind regards Marco

tobias-kuendig commented 7 months ago

Hey @marcogrueter, thank you for this contribution! I've adapted and integrated your changes in 8f9b34a7b4726a037dbfce4a1319a402ea68b3f1. Let me know if you find any issues with this change.

marcogrueter commented 7 months ago

Hi @tobias-kuendig, thank you for accepting the request and the adaption. Works flawlessly for me. Great stuff!