phoenixframework / tailwind

An installer for tailwind
MIT License
475 stars 61 forks source link

Ignore Browserslist warning. #84

Closed linusdm closed 1 year ago

linusdm commented 1 year ago

There is some confusion about the warning that is shown from the Browserslist dependency in the tailwind CLI. See here and here for examples of such confusion.

The warning appears once the Browserslist package is more than six months old. The warning is particularly confusing because it proposes to run an npx command to resolve the issue. Because this is a packaged dependency of the tailwind CLI, this makes no sense. Ideally this would be fixed upstream (I personally think it's not a good idea to print such warnings in the first place), but I don't know how to go about that. See these issues for more background on this potential can of worms. This is an attempt to silence the warning for this particular use-case, which admittedly is less ideal, but gets the job done.

By setting the environment variable BROWSERSLIST_IGNORE_OLD_DATA, the warning about an outdated browserslist can be silenced.

The original warning for completeness:

Browserslist: caniuse-lite is outdated. Please run:
  npx update-browserslist-db@latest
  Why you should do it regularly: https://github.com/browserslist/update-db#readme

This features is not documented in the browserslist project. It's implemented here.

--

Just as an aside: the same can be accomplished without any changes to this package, in user-config only. One can put this in config.exs instead:

# Configure tailwind (the version is required)
config :tailwind,
  version: "3.2.4",
  default: [
    args: ~w(
      --config=tailwind.config.js
      --input=css/app.css
      --output=../priv/static/assets/app.css
    ),
    cd: Path.expand("../assets", __DIR__),
    env: %{"BROWSERSLIST_IGNORE_OLD_DATA" => "1"}
  ]

This has the same effect as it sets the same environment variable from the client config. It uses the :env config key (which is currently not documented).

linusdm commented 1 year ago

I have three failing tests when running mix test locally. I get the same failures when I run the tests without this change. Sometimes only one test fails, sometimes all pass, they seem flaky on my machine. I haven't investigated thoroughly.

chrismccord commented 1 year ago

❤️❤️❤️🐥🔥