arnoson / kirby-vite

Use Kirby CMS together with Vite
MIT License
81 stars 7 forks source link

Is there an easy way to get the paths in the manifest JSON #24

Closed FlorianBoe closed 1 year ago

FlorianBoe commented 1 year ago

First of all, thanks for your plugin! Great work!

In a current project I have the case that I would like to preload a few assets. Especially font files to optimize for CLS.

At the moment I access the path via this code, which is unfortunately very verbose and thus not very secure: /dist/{{ vite().manifest()["fonts/font-name.woff2"]["file"] }}

Would it make sense to add a public function that returns the absolute path for a resource?

arnoson commented 1 year ago

Glad you like the plugin! Seems like a good idea, maybe something like vite()->file(...). Do you want to create a PR? Otherwise I can look into this later this week.

FlorianBoe commented 1 year ago

Thanks for the feature and the quick release!