简体   繁体   中英

Migrating Angular Material to v12 does not remove old import syntax

I upgraded my Angular app to v12, and since I am using Material, I upgraded Material as well.

In the v12 announcement article they said that Material now expose new @use syntax and upgrade should migrate syntax automatically. They also added code example of the new VS old syntax .

So basically @import '~@angular/material/theming; should be replaced with @use '~@angular/material' as mat; .

When I checked changes after upgrade finished successfully, I noticed that in the styles.scss the @use '~@angular/material' as mat; line were added, BUT @import '~@angular/material/theming; line was NOT removed . So now, I have both @use and import in my styles.scss file.

Should I remove @import '~@angular/material/theming; ? As I understand, it will import the same thing twice, so it can only increase the size of the file.

As announced here the new @use is an improvement on how often scss files are imported. Basically both @import and @use work. BUT @use has potentially a better performance.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM