Skip to content

fix(@angular/build): prepend deploy-url to file loader output paths#32880

Closed
maruthang wants to merge 1 commit intoangular:mainfrom
maruthang:fix-32789-deploy-url-file-loader
Closed

fix(@angular/build): prepend deploy-url to file loader output paths#32880
maruthang wants to merge 1 commit intoangular:mainfrom
maruthang:fix-32789-deploy-url-file-loader

Conversation

@maruthang
Copy link
Copy Markdown
Contributor

PR Checklist

PR Type

  • Bugfix

What is the current behavior?

Assets processed by esbuild's file loader (e.g., SVGs imported via import svgUrl from './test.svg') do not get the deploy-url prefix applied. The publicPath option (derived from deployUrl) is passed to stylesheet bundling but not to the application code bundler's common options.

Issue Number: #32789

What is the new behavior?

Pass publicPath through to esbuild's common options in getEsBuildCommonOptions(), so file loader output paths are correctly prefixed with the deploy-url value.

No regression risk: Component stylesheets already explicitly delete publicPath before their own bundling (lines 72 and 127 in component-stylesheets.ts), preventing double-prefixing.

Does this PR introduce a breaking change?

  • Yes
  • No

Pass the publicPath option through to esbuild's common options so that
assets processed by the file loader (e.g., SVGs imported via URL) get
the deploy-url prefix applied, matching the previous webpack behavior.

Fixes angular#32789
Copy link
Copy Markdown

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request updates the esbuild configuration to include the publicPath option, ensuring that file loader import URLs correctly prepend the deployment URL. A new test case was added to verify this behavior for file loaders. I have no feedback to provide.

@clydin
Copy link
Copy Markdown
Member

clydin commented Mar 27, 2026

Thank you for the contribution.

However, these changes affect the entire code bundling process and not just the file loaders. This would need to be handled in a fine-grained manner. But even that type of change may lead to breaking behavior for existing users. Further information is needed from the originating issue regarding a specific use case and reproduction before changes can made.

@maruthang
Copy link
Copy Markdown
Contributor Author

Thanks for the feedback, @clydin. You're right — esbuild's publicPath also affects code-splitting chunk paths, not just file loader outputs.

A more targeted approach would be to modify the loader-import-attribute-plugin.ts to handle file loader imports specially — instead of delegating to esbuild's built-in file loader, the plugin could resolve the output path and prepend deploy-url itself. However, this adds complexity and I'd want to understand the issue reporter's specific use case better first.

I'll close this PR for now. If the issue reporter provides a reproduction, I'm happy to revisit with a fine-grained approach.

@maruthang maruthang closed this Mar 27, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants