Custom vite middleware is not executed for CSS files
- Vorherrschende Sprache
- TypeScript
- Sterne
- 27k
- Forks
- 11.8k
- Ø Merge
- 14 Std. 23 Min.
- Gemergte PRs (30 T.)
- 162
Beschreibung
### 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.
Beitragsleitfaden
Rechercherichtung
Beginnen Sie in packages/angular_devkit/build_angular/src/tools/vite/angular-memory-plugin.ts bei der CSS-Verarbeitung um die Zeilen 163–178 und verfolgen Sie, wie die Vite-Middleware-Kette für Stylesheets abgeschlossen wird. Bestätigen Sie, dass die Änderung die Bereitstellung von CSS beibehält und gleichzeitig ermöglicht, dass benutzerdefinierte Middleware für CSS-Ressourcen ausgeführt wird, und überprüfen Sie anschließend das Verhalten des serve-Befehls.
Vom Indexierungsmodell aus dem Issue-Text verfasst.
Bewertung
- Tech-Stack
- angular, typescript, vite
- Bereich
- build-system, cli
- Issue-Typ
- Bug
- Schwierigkeit
- 3/5
- Geschätzter Aufwand
- 1-2 Tage
- Aktivitätsstatus
- Veraltet
- Klarheit
- Klar beschrieben
- Anfängerfreundlichkeit
- 42/100