我使用angular-cli命令ng new MyProject
创建了一个基本应用程序并禁用全局视图封装我通过添加defaultEncapsulation来更改main.ts文件:bootstrapModule(AppModule,{ defaultEncapsulation: ViewEncapsulation.None })
。
如果我使用ng serve
启动应用程序,它会完美运行,但如果我使用ng serve --prod
,我的配置将被忽略,应用程序将使用ViewEncapsulation.Emulated
(我可以看到_ngcontent属性)开发工具)。知道我错过了什么以及如何在prod构建中设置ViewEncapsulation.None
?我使用angular 4.1.3和angular-cli 1.0.0。
更新
如果我使用ng serve --prod --aot=false
构建应用程序,我的配置也会受到尊重,因此它与aot有关。