angular / angular/angular-cli

Custom vite middleware is not executed for CSS files

Ouverte
#27,110 4 commentaires 0 réactions 0 personnes assignées Voir sur GitHub
needs: more info
Langage dominant
TypeScript
Étoiles
27k
Forks
11.8k
Merge moyen
14 h 23 min
PR mergées (30 j)
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.

Guide de contribution

Ouvrir le guide de contribution

Piste de recherche

Commencez dans packages/angular_devkit/build_angular/src/tools/vite/angular-memory-plugin.ts, au niveau de la gestion du CSS autour des lignes 163–178, et suivez la manière dont la chaîne de middleware Vite est complétée pour les feuilles de style. Vérifiez que la modification préserve le service du CSS tout en permettant l’exécution d’un middleware personnalisé pour les ressources CSS, puis vérifiez le comportement de la commande serve.

Rédigé par le modèle d'indexation à partir du texte de l'issue.

Évaluation

Stack technique
angular, typescript, vite
Domaine
build-system, cli
Type d'issue
Bug
Difficulté
3/5
Temps estimé
1-2 jours
Activité
À l'abandon
Clarté
Clairement spécifiée
Accessibilité débutants
42/100

Recevez les nouvelles issues par e-mail

Un résumé court des issues GitHub adaptées aux débutants.