Implement dev/release build commands
I'd like to perform various optimizations and other changes to make dev builds faster, release builds smaller, and other tweaks .
For Leptos, our build tool cargo-leptos allows us to define these things depending on whether we're building for dev or prod in concert with Cargo. I'd like to be able to give spin different invocations of cargo leptos depending on situation.
Ideally, this would match cargo, so spin build builds the dev version, spin build --release builds the release version, and a --profile= version would all allow users to add different commands in spin.toml
Looks like there was some discussion internally on this that didn't make it onto the issue. Some stuff that came up:
- What do we do about different output locations for dev and release builds?
- Is this effectively going to turn into some
npm run <script>kind of thing? How do we feel about that? - How much complexity are we okay with investing into
spin build? Accreting a feature here and a feature there is going to be more effort for less delight than going "welp looks like we're building a build system, let's do some design."
For me, part of the challenge is that spin build and spin up/spin deploy are decoupled. If I do a dev build followed by spin up, presumably I want to run the dev build... but that means we need to either dev and release build to the same place, or we need to remember the last build command, neither of which feel lovely. Conversely we don't want spin deploy or spin registry push to roll out a dev build just because that's the last one the user happened to build.
Definitely some concerns there, I think it would have to remember the last build. I guess it's up to you whether you want people to be able to push the dev profile, although if I choose a different release profile that checking might get interesting. Perhaps a setting for the desired release-profile as well as different commands?
You could build a full on npm run kinda thing, but at least for this purpose I'm happy to delegate it to Cargo with a few Spin additions.
This is very much a Rust specific thing though, I imagine there's a more general way to do it, perhaps I could build a plugin that does this