-
Notifications
You must be signed in to change notification settings - Fork 12k
Webpack assets modules support #22351
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
Hi @And2s, Thanks for opening this request. However, Webpack specific features are not supported by the Angular CLI. The fact that Webpack is used is an implementation detail that change can in the future. The supported way to references assets in templates and TypeScript files is by using the the |
Hi @alan-agius4, thanks for the info. Will there be a support for something like webpack asset modules in the future? Personally I did not have many implementations but in some cases it is a very useful feature which helps to maintain clear structure. |
I noticed that when web-workers are enabled we allowing parsing This is an inconsistency that we should tackle. We should either allow parsing Side note: Webpack will always replace |
Hi @And2s, We have discussed this during yesterday team meeting. We feel that we shouldn't enable assets modules as this is strictly a Webpack feature which will not work if in the future we move away to a different bundler. We do agree that there is an inconsistency that we finger print assets in CSS but not in HTML templates. Let's continue tracking this in #22510 |
This issue has been automatically locked due to inactivity. Read more about our automatic conversation locking policy. This action has been performed automatically by a bot. |
Which @angular/* package(s) are relevant/releated to the feature request?
No response
Description
Until v13.1.0 was possible to use this implementation to import images:
new URL('./image.png', import.meta.url).pathname
provided by webpack documentation https://webpack.js.org/guides/asset-modules/
Since Angular v13.1.0 this approach does not work.
Proposed solution
Implement support for Webpack asset modules support.
https://webpack.js.org/guides/asset-modules/
Sometimes it is much more convenient to write such imports and provide urls for reusable components e.g. <app-landing-block [image]="url">. Without imports in .ts files, the images must be always predefined directly in component and imported through .scss / .less file. And such an approach sometimes becomes too difficult depending on situation.
Alternatives considered
Currently it is only possible to import image through .scss / .less file or directly into assets folder.
The text was updated successfully, but these errors were encountered: