-
-
Notifications
You must be signed in to change notification settings - Fork 205
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
The new minimize feature is causing Angular build to fail #269
Comments
@JonWallsten What is a problem? Maybe we can fix it on loader side |
@evilebottnawi I get hundreds of error, but they are all of the same kind.
So something is happening with the template (i use external html files) that causes Angular to not being able to compile. I'm using their new compiler IVY which makes it even worse trying to figure out what's happening. |
@JonWallsten Can you create reproducible test repo? I want to investigate and look what we can do |
Sure! I'll send you an invite to a private repo as soon as it's done. |
Great! |
I'm having the same issue with angular prod builds. Went back to html-loader 0.5.5 for now |
@evilebottnawi: You're invited now. I'll add instructions in an open issue in the repo. |
@JonWallsten Thanks I will look at that tomorrow ⭐ |
I found a solution for the problem. The console output in my application was
I noticed that ngif is mentioned in small case So the following config of html-minifier-terser did the trick
The caseSensitive option is false by default. I also experimented with the customAttrAssign option but as far as I can tell, all angular attributes are working out of the box. Edit:
(since removeAttributeQuotes is false by default, the option could be removed in https://github.com/webpack-contrib/html-loader/blob/master/src/plugins/minimizer-plugin.js) |
@chumbalum: Nice find! Now I feel embarrassed I didn't even take the time to realize my own template variables were all in lowercase in the error messages. |
@chumbalum Thanks for investigation, maybe we can detect what it is angular template and uses other settings for minimizer, if not we should documented that |
I really think html loader should not be responsible for the minification. or at least this should be opt-in, not opt-out I'm using html-loader in a pipeline, so that other loaders come after it. During the minify phase html-loader removed attribute quotes because the values did not have any spaces in them but after the next loader (which is handlebars-loader) expanded the variables the html became broken Moreover, since minification by default only happens in production, the issue was only caught on CI (good thing we run them in prod mode, which as i know not everybody does) UPD: I know about the preprocess option but i can't use it since i'm using handlebars with marionette and marionette expects the template to be a function and not a string |
@dreyks we already use minimizer in production mode - for js/css/html/etc, it is good DX to set
Please procide reproducible test repo, I will think how we can improve it |
@chumbalum Thanks for your solution, this example works for me (with removeAttributeQuotes: true):
|
@Zadvornyi Can you create reproducible test repo? I want to fix it on |
The config above doesn't work for me on Angular 10 (without aot)... :(
|
@stnor Can you provide minimum reproducible test? |
Zip file with minimum reproducible test (I don't use AngularCompilerPlugin yet as I have a large legacy app that's hybrid ng1 and ng10). my test case looked like this:
|
Thanks! |
So I guess |
Look like bug in https://github.com/DanielRuf/html-minifier-terser |
Can you open an issue? |
Problem with I think we can set What do you think? |
@evilebottnawi I think it is probably better if you open an issue with html-minifier-terser. I have moved on to more pressing matters. Your proposed solution for html-loader sounds good to me. |
Somebody can provide spec on |
And why html-loader uses on angular ivy tempaltes? |
Expected Behavior
The default configuration should not mess up the build for all Angular users
Actual Behavior
Since minimize is enabled as default for production builds it automatically fails Angular's production build when you update this package.
How Do We Reproduce?
Use Webpack and AngularCompilerPlugin to compile you Angular build.
I will close this as soon as it's created. I just want people to be able to search for this issue so they don't have to dig into this like I had to.
Solution
Turn of minimize:
Keywords: html-loader webpack angular build fail ivy compile
The text was updated successfully, but these errors were encountered: