angular / angular/angular-cli

Tailwind JIT not updating styles when using styleUrls

Aperta
#24,469 6 commenti 0 reazioni 0 assegnatari Vedi su GitHub
area: @ngtools/webpack freq1: low severity3: broken type: bug/fix
Lingua principale
TypeScript
Stelle
27k
Fork
11.8k
Merge medio
14h 23m
PR unite (30g)
162

Descrizione

### Command

serve

### 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 using `styleUrls` to specify the path to the tailwind css entrypoint file separately, the JIT will not detect changes properly.

To clarify:

```ts
@Component({
selector: 'app-root',
templateUrl: './app.component.html',
styleUrls: ['./app.component.scss', '../tailwind.css'] // notice tailwind is separated here
})
```

Now if I try to use any class that is not already used in the HTML, the changes will not propagate properly. Only killing `ng serve` and restarting it will work.

I have attached a simple repro.

### Minimal Reproduction

Repro at:

https://github.com/andreialecu/angular-tw-jit-repro

Run
```
yarn
yarn start
```

Open `http://localhost:4200/` in the browser.

Then go into `app.component.html` and try to change `bg-green-200` to `bg-red-200`, you will see that the background disappears because `bg-red-200` does not exist.

If you ctrl+c then run `yarn start` again, the background will update.

### Exception or Error

_No response_

### Your Environment

```text
Angular CLI: 13.3.10
Node: 16.14.2
Package Manager: yarn 1.22.19
OS: darwin arm64

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

Package Version
---------------------------------------------------------
@angular-devkit/architect 0.1303.10
@angular-devkit/build-angular 13.3.10
@angular-devkit/core 13.3.10
@angular-devkit/schematics 13.3.10
@angular/cli 13.3.10
@schematics/angular 13.3.10
rxjs 7.5.7
typescript 4.6.4
```

### Anything else relevant?

Possibly related:

https://github.com/angular/angular-cli/issues/21749
https://stackoverflow.com/a/73446036

Guida per i contributori

Apri la guida per i contributori

Direzione di ricerca

Inizia con la riproduzione minima collegata: esegui yarn, quindi yarn start, e modifica app.component.html mentre tailwind.css è elencato separatamente in styleUrls. Osserva lo stile di sfondo generato prima e dopo il riavvio del processo serve. È completato quando la modifica di una classe Tailwind precedentemente inutilizzata aggiorna gli stili serviti senza riavviare.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Valutazione

Stack tecnologico
angular, tailwindcss, typescript
Ambito
build-system, frontend
Tipo di issue
Bug
Difficoltà
4/5
Tempo stimato
3-5 giorni
Stato di attività
Ferma
Chiarezza
Abbastanza chiara
Idoneità per principianti
45/100

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.