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

Add --bin-skip flag to build command #212

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

CorvusPrudens
Copy link

@CorvusPrudens CorvusPrudens commented Nov 10, 2023

Utility

In certain pipelines, it is convenient to use cargo-leptos to build the lib target and associated files only. This can be done currently by re-implementing the functionality cargo-leptos provides manually, but that may require parsing the project's Cargo.toml, and it certainly requires more knowledge of the build process than is otherwise required to successfully use cargo-leptos.

An example where this is especially useful is a deploy pipeline for an AWS Lambda function. The server binary destined for the function must, among other things, target a particular architecture. cargo-lambda makes this very easy to achieve. Of course, the lib target and associated files do not require anything different, so they can be built with cargo-leptos as normal. Here's what this might look like currently:

cargo leptos build --release
cargo lambda build --no-default-features --features=ssr --release
cargo lambda deploy --include target/site --enable-function-url

In this sequence, the bin target is built twice. With a --bin-skip flag, it would only be built once:

cargo leptos build --release --bin-skip
cargo lambda build --no-default-features --features=ssr --release
cargo lambda deploy --include target/site --enable-function-url

Implementation

My implementation is rather quick and dirty. I wanted to avoid adding a flag to all the subcommands when it only makes sense for build. Duplicating a large struct only to change one member is not ideal though. If there's a better approach for this feature, I'm all ears! I also totally understand if this feature isn't all that appropriate at the end of the day.

It may also make more sense to provide mutually exclusive flags (or an option of some sort) so either target can be skipped.

@luxalpa
Copy link
Contributor

luxalpa commented May 2, 2024

I think instead of skipping targets it would be nicer if we could be listing targets, like build server, build client, etc

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

Successfully merging this pull request may close these issues.

2 participants