Custom vite middleware is not executed for CSS files
- Lingua principale
- TypeScript
- Stelle
- 27k
- Fork
- 11.8k
- Merge medio
- 14h 23m
- PR unite (30g)
- 162
Descrizione
### 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.
Guida per i contributori
Apri la guida per i contributori
Direzione di ricerca
Inizia in packages/angular_devkit/build_angular/src/tools/vite/angular-memory-plugin.ts, nella gestione del CSS intorno alle righe 163–178, e segui come viene completata la catena di middleware di Vite per i fogli di stile. Verifica che la modifica preservi la distribuzione del CSS consentendo al middleware personalizzato di essere eseguito per le risorse CSS, quindi verifica il comportamento del comando serve.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Valutazione
- Stack tecnologico
- angular, typescript, vite
- Ambito
- build-system, cli
- Tipo di issue
- Bug
- Difficoltà
- 3/5
- Tempo stimato
- 1-2 giorni
- Stato di attività
- Ferma
- Chiarezza
- Specificata chiaramente
- Idoneità per principianti
- 42/100