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

Ignore Browserslist warning. #84

Merged
merged 2 commits into from
May 12, 2023

Conversation

linusdm
Copy link
Contributor

@linusdm linusdm commented Apr 28, 2023

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).

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

```
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](https://github.com/browserslist/browserslist/blob/main/node.js#L389).
@linusdm
Copy link
Contributor Author

linusdm commented Apr 28, 2023

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.

lib/tailwind.ex Outdated Show resolved Hide resolved
@chrismccord chrismccord merged commit b3f8418 into phoenixframework:main May 12, 2023
@chrismccord
Copy link
Member

❤️❤️❤️🐥🔥

@linusdm linusdm deleted the browserslist_warning branch May 12, 2023 17:51
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