Skip to content

Angular CLI does not apply custom webpack loader #18474

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

Closed
abadakhshan opened this issue Aug 7, 2020 · 6 comments
Closed

Angular CLI does not apply custom webpack loader #18474

abadakhshan opened this issue Aug 7, 2020 · 6 comments

Comments

@abadakhshan
Copy link

abadakhshan commented Aug 7, 2020

Angular CLI does not apply custom webpack loader

I define custom webpack and add a custom loader for ts or html files but loader transformation does not apply on output.

it seems that Angular CLI uses its own mechanism for reading files.

readFile(fileName: string): string | undefined {

Sample repository: https://github.com/abadakhshan/test-custom-loader

@alan-agius4
Copy link
Collaborator

Duplicate of #16544

@alan-agius4 alan-agius4 marked this as a duplicate of #16544 Aug 7, 2020
@abadakhshan
Copy link
Author

What is the alternative solution to this problem?
Is it possible that we have transformers for all files like we have for index.html?

@alan-agius4
Copy link
Collaborator

The alternatives depend on what you are trying achieve with your "loader".

@abadakhshan
Copy link
Author

abadakhshan commented Aug 7, 2020

Hi @alan-agius4
I want to do some transformation on HTML files before angular compilition.
I use this approche to apply Html template merging
In angular 9 I did it with injecting some code in Angular compiler plugin but I think if I can do this with loader , it would be better.
Yoy can see my old code here:

https://github.com/NarikMe/narik-webpack-tools/blob/master/narik-compiler-plugin.js

@alan-agius4
Copy link
Collaborator

You need to disable directTemplateLoading of the angularCompilerPlugin via a custom builder.

See http://github.com/angular/angular-cli/issues/15861 for some more context.

Note: this approach is not supported by the Angular tooling team.

@angular-automatic-lock-bot
Copy link

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.

@angular-automatic-lock-bot angular-automatic-lock-bot bot locked and limited conversation to collaborators Sep 7, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants