Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Custom vite middleware is not executed for CSS files #27110

Open
Labels
needs: more infoReporter must clarify the issue
@kamilchlebek

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.

if (extension !== '.js' && extension !== '.html') {
const outputFile = outputFiles.get(pathname);
if (outputFile?.servable) {
const mimeType = lookupMimeType(extension);
if (mimeType) {
res.setHeader('Content-Type', mimeType);
}
res.setHeader('Cache-Control', 'no-cache');
if (extraHeaders) {
Object.entries(extraHeaders).forEach(([name, value]) => res.setHeader(name, value));
}
res.end(outputFile.contents);
return;
}
}

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    needs: more infoReporter must clarify the issue

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions

        AltStyle によって変換されたページ (->オリジナル) /