Custom vite middleware is not executed for CSS files
- Ngôn ngữ chính
- TypeScript
- Star
- 27k
- Fork
- 11.8k
- Merge trung bình
- 14 giờ 23 phút
- Pull request đã merge (30 ngày)
- 162
Mô tả
### 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.
Hướng dẫn đóng góp
Hướng nghiên cứu
Bắt đầu tại packages/angular_devkit/build_angular/src/tools/vite/angular-memory-plugin.ts, ở phần xử lý CSS quanh các dòng 163–178, và theo dõi cách chuỗi middleware của Vite được hoàn tất cho các stylesheet. Xác nhận rằng thay đổi này vẫn duy trì việc phục vụ CSS, đồng thời cho phép middleware tùy chỉnh chạy đối với các tài nguyên CSS, sau đó kiểm tra hành vi của lệnh serve.
Do mô hình lập chỉ mục viết ra từ nội dung của issue.
Đánh giá
- Công nghệ
- angular, typescript, vite
- Lĩnh vực
- build-system, cli
- Loại issue
- Lỗi
- Độ khó
- 3/5
- Thời gian dự kiến
- 1-2 ngày
- Mức độ hoạt động
- Đình trệ
- Độ rõ ràng
- Đặc tả rõ ràng
- Mức phù hợp với người mới
- 42/100