modernWebDevBuild icon indicating copy to clipboard operation
modernWebDevBuild copied to clipboard

HTML minification breaks Angular 2

Open dsebastien opened this issue 10 years ago • 6 comments

Angular 2 does not seem to like:

ngFor vs ngfor
routerLink vs routerlink
<blockquote cite="http://www.google.be">...</blockquote> vs <blockquote cite=http://www.google.be>...</blockquote>

These are modifications that https://www.npmjs.com/package/gulp-minify-html does by default via https://github.com/Swaagie/minimize. The behavior with quotes can be changed but not that with case sensitivity

dsebastien avatar Dec 20 '15 11:12 dsebastien

This is known: https://github.com/angular/angular/issues/5789

dsebastien avatar Dec 20 '15 11:12 dsebastien

Apparently the solution proposed by the Angular team will be an offline template compiler, meaning that we'll have to branch depending on whether the client project uses Angular or not

dsebastien avatar Dec 20 '15 11:12 dsebastien

Issue to keep an eye on: https://github.com/Swaagie/minimize/issues/74

dsebastien avatar Dec 20 '15 11:12 dsebastien

For now, a workaround is to use the new option to disable HTML minification.

gulpfile.babel.js:

options.minifyProductionHTML = false; // HTML minification is not supported by Angular 2 anymore: https://github.com/dsebastien/modernWebDevBuild/issues/67

dsebastien avatar Dec 20 '15 12:12 dsebastien

I had same problem with minify Angular2. It seem has been fix when bump minimize version from 1.7.4 to 1.7.5 (now is 1.8.1?) and added the "dom" option.

dom: {
    lowerCaseAttributeNames: false
}

yizhan avatar Jan 12 '16 02:01 yizhan

Thanks for the tip @yizhan I'll try this out!

dsebastien avatar Jan 12 '16 05:01 dsebastien