How to use Vite inside an addon during development #8851
-
I'm currently developing an addon in Statamic and have encountered a scenario related to styling my tags. I've decided to utilize Vite, and possibly Tailwind, for bundling my assets. Following the documentation, I've successfully configured my scripts and styles, with the $vite property, and they are automatically loaded in the control panel, which is great. However, I specifically need these assets to be applied on the frontend rather than the control panel. My question is: How can I reference my active Vite server (inside the addon) to serve that CSS before it is bundled, ensuring that the styles are applied on the frontend during development? |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 3 replies
-
Are you using the Vite tag? |
Beta Was this translation helpful? Give feedback.
-
@rogerthat-be Is this also the final line in your view for the tag on production environments when published? How does that look like? |
Beta Was this translation helpful? Give feedback.
After some trial & error, I've successfully managed to get it working. The tag below (with both the "hot" and "directory" attributes) is essential when working within an addon directory.
{{ vite src="resources/js/addon.js|resources/css/addon.css" hot="addons/rogerthat-be/myaddon/resources/dist/hot" directory="vendor/myaddon/build" }}
Thanks Jason