angular / angular/angular-cli

Custom vite middleware is not executed for CSS files

Abierto
#27,110 4 comentarios 0 reacciones 0 asignados Ver en GitHub
needs: more info
Lenguaje dominante
TypeScript
Estrellas
27k
Forks
11.8k
Merge medio
14 h 23 min
PR fusionados (30 d)
162

Descripción

### 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.

Guía de contribución

Abrir la guía de contribución

Línea de trabajo

Comienza en packages/angular_devkit/build_angular/src/tools/vite/angular-memory-plugin.ts, en el manejo de CSS alrededor de las líneas 163–178, y sigue cómo se completa la cadena de middleware de Vite para las hojas de estilo. Confirma que el cambio conserva la entrega de CSS y permite que el middleware personalizado se ejecute para los recursos CSS; después, verifica el comportamiento del comando serve.

Escrito por el modelo de indexación a partir del texto del issue.

Evaluación

Stack tecnológico
angular, typescript, vite
Área
build-system, cli
Tipo de issue
Error
Dificultad
3/5
Tiempo estimado
1-2 días
Estado de actividad
Estancado
Claridad
Bien especificado
Aptitud para principiantes
42/100

Recibe los nuevos issues en tu correo

Un resumen breve de issues de GitHub para principiantes.