angular / angular/angular-cli

Tailwind JIT not updating styles when using styleUrls

未關閉
#24,469 6 則留言 0 個 reaction 已指派 0 人 在 GitHub 檢視
area: @ngtools/webpack freq1: low severity3: broken type: bug/fix
主要語言
TypeScript
星號
27k
分支
11.8k
平均合併
14 小時 23 分鐘
30 天內合併 PR
162

描述

### 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

貢獻指南

開啟貢獻指南

研究方向

從連結的最小重現開始:執行 yarn,接著執行 yarn start,並在 tailwind.css 個別列於 styleUrls 中時編輯 app.component.html。觀察重新啟動 serve 程序前後產生的背景樣式。當修改先前未使用的 Tailwind 類別後,無需重新啟動即可更新提供中的樣式時,即表示完成。

由索引模型根據 Issue 內容生成。

評估

技術堆疊
angular, tailwindcss, typescript
領域
build-system, frontend
Issue 類型
缺陷
難度
4/5
預估耗時
3-5 天
活躍度
停滯
描述清晰度
基本清楚
新手友好度
45/100

把新 issue 寄到你的電子郵件信箱

精選適合新手參與的 GitHub issue 摘要。