You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Extensionless static asset files fail with vite:import-analysis error during dev server #32560
Yes, this behavior used to work in the previous version
The previous version in which this bug was not present was
No response
Description
Static asset files with no file extension cause a vite:import-analysis parse error during ng serve. This is the same class of issue as #30798 (which covered html and .br files), but for extensionless files.
The error occurs because the assets middleware in createAngularAssetsMiddleware only serves JS/TS/CSS files directly, other files including extensionless ones are rewritten to @fs/ URLS and forwarded to Vite's transform pipeline. Vite's internal isJSRequest() then treats any URL without a file extension as JavaScript and attempts to parse the binary content.
Minimal Reproduction
Create a new project npx @angular/cli@21 new repro --minimal --skip-git && cd repro
Configure an asset directory with an output path. In angular. json, add to the assets array: { "glob": "**/*", "input": "src/assets", "output": "/assets" }
import(Component,inject,onInit}from @angular/core';
import(HttpClient)from "@angular/common/http';
@Component({selector: 'app-root',template: '<p>Check the terminal for the vite:import-analysis error.</p>',})exportclassAppimplementsOnInit{privatehttp=inject(HttpClient);ngOnInit(){this.http.get('/assets/MyExtensionlessFile',{responseType: 'arraybuffer'}).subscribe({next: ()=>console.log('File loaded successfully'),error: (err)=>console.error('Failed to load file:',err),});}}
In src/app/app.config.ts, add provideHttpClient() to the providers array.
Serve and open in browser ng serve
Expected behavior: The file is served as a binary asset.
Actual behavior: Internal server error.
Exception or Error
[vite] Internal server error: Failed to parse source for import analysis because the content contains invalid JS syntax. If you are using JSX, make sure to name the file with the .jsx or .tsx extension.
Activity
fix(@angular/build): serve extensionless assets without transformation
nizos commentedon Feb 25, 2026
Thanks for the quick action @alan-agius4, much appreciated!
angular-automatic-lock-bot commentedon Mar 28, 2026
This issue has been automatically locked due to inactivity.
Please file a new issue if you are encountering a similar or related problem.
Read more about our automatic conversation locking policy.
This action has been performed automatically by a bot.