angular / angular/angular-cli

Custom vite middleware is not executed for CSS files

未關閉
#27,110 4 則留言 0 個 reaction 已指派 0 人 在 GitHub 檢視
needs: more info
主要語言
TypeScript
星號
27k
分支
11.8k
平均合併
14 小時 23 分鐘
30 天內合併 PR
162

描述

### Command

serve

### Description

We are in the process of migrating from using webpack to esbuild/vite.

For development purposes, we need a way to dynamically switch from one theme to another. At this point, we have achieved it by proxying CSS or image files depending on the host name.

After switching to Vite, it turned out that it could work the same, apart from the fact that for CSS resources, our middleware is never executed.

I found a piece of code that seems to be the root cause. The `AngularMemoryPlugin` handles CSS files in a specific way and never executes `next()`, which terminates the middleware chain.

https://github.com/angular/angular-cli/blob/3d7b5f78bdab834cb50c441296c9bf31f7a5e764/packages/angular_devkit/build_angular/src/tools/vite/angular-memory-plugin.ts#L163-L178

### Describe the solution you'd like

Ideally middleware chain should not be terminated in `AngularMemoryPlugin` for stylesheets (ie. `next()` should be called)

### Describe alternatives you've considered

In the worst case scenario, we will find another solution for our use case. However, since the issue only pertains to CSS files, it would be really helpful if the middleware is executed for these files as well.

貢獻指南

開啟貢獻指南

研究方向

從 packages/angular_devkit/build_angular/src/tools/vite/angular-memory-plugin.ts 中第 163–178 行附近的 CSS 處理開始,追蹤 Vite middleware 鏈如何為樣式表完成。確認此變更在保留 CSS 提供功能的同時,允許自訂 middleware 處理 CSS 資源,然後驗證 serve 命令的行為。

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

評估

技術堆疊
angular, typescript, vite
領域
build-system, cli
Issue 類型
缺陷
難度
3/5
預估耗時
1-2 天
活躍度
停滯
描述清晰度
描述清楚
新手友好度
42/100

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

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