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

Only download tailwind binaries if none are present #84

Open
sbrow opened this issue Jan 23, 2025 · 1 comment
Open

Only download tailwind binaries if none are present #84

sbrow opened this issue Jan 23, 2025 · 1 comment

Comments

@sbrow
Copy link

sbrow commented Jan 23, 2025

TL; DR - Would you be open to a PR that makes tailwind:build update less aggressively?

I came to work today to a failing tailwind build. While investigating this problem,
I discovered that my ./var/tailwind directory contained at least 4 different versions of
the tailwind binary, which I presume means that this bundle always looks for and downloads the latest version
of tailwind when running console tailwind:build.

While I understand that not everyone likes to be chained to strictly pinned dependencies (praise be to Nix), I think that it would be a more sensible default to check if there is any version
of tailwind already downloaded, and if so, only download a different one if a pinned version has been configured, and none of the downloaded versions match the configuration.

Suddenly updating users to a major revision without any notice is a bit jarring.

Let me know if this sounds good to you, and thank you for letting us pin a specific version.

Below is some pseudo code of what I'm thinking:

<?php

/**
  * Downloads tailwind if necessary.
  * @return The version of binary that will be used.
  * /
function maybe_download_tailwindss($user_config): string {
    $downloaded_versions = find_downloaded_tailwind_binaries();
    $pinned_version = $user_config->binary_version;

    if ($pinned_version) {  
        if (in_array($pinned_version, $downloaded_versions)) {
            return $pinned_version;
        } else {
            return download_tailwind($pinned_version);
        }
    } else {
        if (empty($downloaded_versions)) {
            return download_tailwind('latest');
        } else {
            // Here you could check if a newer version exists upstream and inform the user.

            return end($downloaded_versions); // assuming versions are sorted in ascending order.
        }
    }
}
@kbond
Copy link
Contributor

kbond commented Jan 24, 2025

Yep, I can see the value in this.

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