Custom vite middleware is not executed for CSS files
- Dominant language
- TypeScript
- Stars
- 27k
- Forks
- 11.8k
- Avg merge
- 14h 23m
- Merged PRs (30d)
- 162
Description
### 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.
Contributor guide
Research direction
Start in packages/angular_devkit/build_angular/src/tools/vite/angular-memory-plugin.ts at the CSS handling around lines 163–178, and trace how the Vite middleware chain is completed for stylesheets. Confirm the change preserves CSS serving while allowing custom middleware to run for CSS resources, then verify the serve command behavior.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- angular, typescript, vite
- Domain
- build-system, cli
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Clearly specified
- Newbie friendliness
- 42/100