Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Document the process of building assets for addons #1421

Open
duncanmcclean opened this issue Jul 22, 2024 · 1 comment
Open

Document the process of building assets for addons #1421

duncanmcclean opened this issue Jul 22, 2024 · 1 comment

Comments

@duncanmcclean
Copy link
Member

This question has just come up on Discord:

Does anyone have any tips on how to distribute assets for an addon? I am developing an addon that needs some js and css on the frontend to work, I created frontend assets using vite but when used with the vite tag they only work for npm run build not dev

My response was:

You can either:

  1. Build them manually before you tag a release and include them in the Git repository. Then, in your service provider, you can publish the files to the site's public/vendor directory.
  2. A little more advanced way (which we do at Statamic, and I use for my addons), is to ignore committing assets to the repository, then building them as part of a GitHub Actions workflow used for releasing. Jason's built a package which'll then copy over the assets from the GitHub release into the site's vendor directory upon composer update.

It feels like we could do with some more detailed documentation around how addon developers should handle this.

@afonic
Copy link

afonic commented Jul 24, 2024

Hey Duncan thanks for this and for your help. Just to add my notes and possibly I could help with writing a draft if I get all my facts straight.

Building assets for the frontend and the backend is a bit more complex and just one or the other. If we assume that the dependencies can be the same, we can probably document how to have separate vite config files?

Also I am not 100% sure what is the recommended way to distribute them. For the Statamic form helper you've used a "normal" import, however that leaves cache busting to the dev. In some addons the frontend assets might change often. Maybe we need to document also how to include them using the Vite tag or something similar?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants