Add cssAsset method to get associated css files to an asset #5
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Hey @lukaskleinschmidt,
thank you very much for this plugin!
I have a small feature request that I hope you might consider. I've a built a plugin called kirby-asset-manager that allows one to include assets on a snippet / block level. I use this to minimize the css / js files on the page, if a certain block is not being used.
To get the urls from Vite, I use the asset method from your plugin like so:
That works perfectly, but there is one issue when using more complex components (e.g. Svelte). On built, Vite will extract the css into it's own files that are associated with the asset itself.
Using the
vite()->asset()
method alone, will only return the javascript file, which is expected. This is why I added avite()->assetCss()
method to resolve thecss
array on those files.