I am developing a library of components, how to ship the "compiled" assets?

I am developing a library of components.
Which options I have to ship the compiled css and javascript with it?

Here are some requirements I would love to fulfill:

  1. My components should be pluggable into any existing Phoenix project (I can assume >= 1.7.0)
  2. I would love to minimize the steps to be taken to use my library
  3. I don’t need the library css and javascript to be modified, they can be used as-is
  4. I would like to don’t have to keep the compiled css and javascript under version control
  5. It should be possible to use my library as a path dependency

Thank you

Can’t you just place the precompiled css/js in the priv folder and reference them from there?

I’d suggest going with the same approach phoenix libraries go with: compile to some retained folder (likely priv/) folder, have a package.json in the root, which references the files. In the end the dependency becomes a npm package like many others.

1 Like

May I ask you the name of one of these libraries?

Phoenix Liveview for example.

1 Like

So IIUC I must keep the compiled bundles under version control

Not necessarily, but that’s what LiveView does. If you don’t keep them in version control, and just build shortly before releasing to hex.pm, then your package will not be usable when pointed to it with {:mylib, github: "some/lib"}. I don’t think there’s a good way to avoid having compiled assets available without committing them to repo.


Thank you all!

Love this community

1 Like