When developing a hex package intended to be used with Phoenix projects, such as a component library, plug,
on_mount
callback, or any other piece of shared code, Phoenix needs some extra configuration to enable the great developer experience we have come to expect. By default, a Phoenix app will only reload its own code, and only prompt the browser to live reload when you make changes to files in that project. So this makes it challenging if you're making changes to a mix package in one directory, and testing with a Phoenix project in another.This is a quick guide on a few ways I've found to configure Phoenix that makes developing a package much nicer, and enables live reloading for faster iterations while developing.
Read on for some explanation behind how Phoenix does code and live reloading, or skip to one of these solutions to bootstrap your project with.
- Option 1: Creating two "sibling" projects, your package and a Phoenix project, side by side in the same parent directory. (Similar to a poncho project.)
- Option 2: Creating a Phoenix project as a subdir inside your package dir, all as a monorepo.
- Option 3: Using an umbrella project and publishing your library straight from its "app/" subdirectory. (Not recommended)
continue reading on blog.lotech.org
⚠️ This post links to an external website. ⚠️
If this post was enjoyable or useful for you, please share it! If you have comments, questions, or feedback, you can email my personal email. To get new posts, subscribe use the RSS feed.