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

esbuild: Using Tailwind breaks stylesheet processing for CSS @imports with URLs ending in .css #28113

Closed
1 task
JulienZD opened this issue Jul 26, 2024 · 1 comment · Fixed by #28116
Closed
1 task
Assignees

Comments

@JulienZD
Copy link

JulienZD commented Jul 26, 2024

Command

build

Is this a regression?

  • Yes, this behavior used to work in the previous version

The previous version in which this bug was not present was

No response

Description

When Tailwind is configured in a project (maybe just PostCSS), any @import url() statement with a URL ending in .css (such as @import url(https://fonts.googleapis.com/earlyaccess/notokufiarabic.css); causes the build to fail, as the url is deemed a local file by the language filters passed to StyleSheetPluginFactory.create(). The create method seems to register an esbuild onLoad handler that will read the path as a local file

Any URLs ending in .less, .scss or .sass are also affected.

In our case we can't easily remove .css from the imported URL, as it's defined by an imported third party CSS file.

Minimal Reproduction

  1. Create a new project with ng new
  2. Install Tailwind by following the Tailwind + Angular installation guide
  3. Add the following to src/styles.css: @import url(https://fonts.googleapis.com/earlyaccess/notokufiarabic.css);
  4. Run npm run build
  5. The build fails, as the URL is attemped to be read as a local file

When no Tailwind config file is present, the build runs fine:

  1. Remove tailwind.config.js and the @tailwind lines from the CSS file, while keeping the @import url()
  2. Run npm run build
  3. The build succeeds

Exception or Error

ENOENT: no such file or directory, open 'https://fonts.googleapis.com/earlyaccess/notokufiarabic.css' [plugin angular-css]

Your Environment

Angular CLI: 18.1.2
Node: 20.14.0
Package Manager: npm 10.7.0
OS: darwin arm64

Angular: 18.1.2
... animations, cli, common, compiler, compiler-cli, core, forms
... platform-browser, platform-browser-dynamic, router

Package                         Version
---------------------------------------------------------
@angular-devkit/architect       0.1801.2
@angular-devkit/build-angular   18.1.2
@angular-devkit/core            18.1.2
@angular-devkit/schematics      18.1.2
@schematics/angular             18.1.2
rxjs                            7.8.1
typescript                      5.5.4
zone.js                         0.14.8

Anything else relevant?

No response

@JulienZD JulienZD changed the title Using Tailwind breaks stylesheet processing for CSS @imports with URLs ending in .css esbuild: Using Tailwind breaks stylesheet processing for CSS @imports with URLs ending in .css Jul 26, 2024
@alan-agius4 alan-agius4 added type: bug/fix freq1: low Only reported by a handful of users who observe it rarely severity3: broken area: @angular/build labels Jul 26, 2024
@alan-agius4 alan-agius4 self-assigned this Jul 26, 2024
alan-agius4 added a commit to alan-agius4/angular-cli that referenced this issue Jul 26, 2024
…hen Tailwind is configured

This addresses a bug where `@import url()` statements with remote CSS files (ending in .css) caused build errors when Tailwind was present. The issue arised from incorrect handling of remote URLs by the stylesheet plugin, which treated them as local files. This fix ensures proper handling of remote CSS imports.

Closes angular#28113
alan-agius4 added a commit to alan-agius4/angular-cli that referenced this issue Jul 26, 2024
…hen Tailwind is configured

This addresses a bug where `@import url()` statements with remote CSS files (ending in .css) caused build errors when Tailwind was present. The issue arised from incorrect handling of remote URLs by the stylesheet plugin, which treated them as local files. This fix ensures proper handling of remote CSS imports.

Closes angular#28113
alan-agius4 added a commit to alan-agius4/angular-cli that referenced this issue Jul 29, 2024
…hen Tailwind is configured

This addresses a bug where `@import url()` statements with remote CSS files (ending in .css) caused build errors when Tailwind was present. The issue arised from incorrect handling of remote URLs by the stylesheet plugin, which treated them as local files. This fix ensures proper handling of remote CSS imports.

Closes angular#28113
alan-agius4 added a commit to alan-agius4/angular-cli that referenced this issue Jul 29, 2024
…hen Tailwind is configured

This addresses a bug where `@import url()` statements with remote CSS files (ending in .css) caused build errors when Tailwind was present. The issue arised from incorrect handling of remote URLs by the stylesheet plugin, which treated them as local files. This fix ensures proper handling of remote CSS imports.

Closes angular#28113
alan-agius4 added a commit to alan-agius4/angular-cli that referenced this issue Jul 29, 2024
…hen Tailwind is configured

This addresses a bug where `@import url()` statements with remote CSS files (ending in .css) caused build errors when Tailwind was present. The issue arised from incorrect handling of remote URLs by the stylesheet plugin, which treated them as local files. This fix ensures proper handling of remote CSS imports.

Closes angular#28113
alan-agius4 added a commit that referenced this issue Jul 29, 2024
…hen Tailwind is configured

This addresses a bug where `@import url()` statements with remote CSS files (ending in .css) caused build errors when Tailwind was present. The issue arised from incorrect handling of remote URLs by the stylesheet plugin, which treated them as local files. This fix ensures proper handling of remote CSS imports.

Closes #28113

(cherry picked from commit 7d52941)
@angular-automatic-lock-bot
Copy link

This issue has been automatically locked due to inactivity.
Please file a new issue if you are encountering a similar or related problem.

Read more about our automatic conversation locking policy.

This action has been performed automatically by a bot.

@angular-automatic-lock-bot angular-automatic-lock-bot bot locked and limited conversation to collaborators Aug 29, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
2 participants