简体   繁体   English

.Net Core 2 SPA /角度模板-渲染全局CSS

[英].Net Core 2 SPA/Angular Template - Render Global CSS

I am very new to Webpack and the .NET Core 2 Angular SPA Template . 我是Webpack和.NET Core 2 Angular SPA模板的新手。 I'm trying to create a global stylesheet for the entire site. 我正在尝试为整个网站创建一个全局样式表 I could reference that style in the Layout view to render it in the main view, but then I lose the benefits of the pre-render engine and bundling with WebPack (as well as minification). 我可以在“布局”视图中引用该样式以在主视图中进行渲染,但是随后我失去了预渲染引擎和与WebPack捆绑在一起(以及缩小)的好处。

The Webpack documentation says that in order to include static CSS that you need to add a require(../filepath) to your module, but I don't see a way to do this in the boot.browser.ts. Webpack文档说,为了包括静态CSS,您需要在模块中添加一个require(../ filepath),但是在boot.browser.ts中我看不到这样做的方法。

I'm still just getting started with .NET core so my site is basically just the OOB .Net Core 2 template with Angular. 我仍然只是.NET Core入门,所以我的站点基本上只是Angular的OOB .Net Core 2模板。 I'm keeping my global styles sheet in ClientApp/Styles/Global.css at the moment. 我现在将全局样式表保存在ClientApp / Styles / Global.css中。 Thanks for your time. 谢谢你的时间。

As in visual studio 2019 Angular template with ASP.Net Core 2.2 you don't have to manage webpack file like old version. 就像在Visual Studio 2019带有ASP.Net Core 2.2的Angular模板中一样,您不必像旧版本一样管理webpack文件。 I'm assume that you are using Angular 5 with webpack template. 我假设您正在将Angular 5与webpack模板一起使用。

Create ASP.Net Core app like this 像这样创建ASP.Net Core应用

在此处输入图片说明

Then you will see style.css in your angular app. 然后,您将在角度应用程序中看到style.css。 That is where you put your global style 那就是您放下全球风格的地方

在此处输入代码

Hope it will help you. 希望对您有帮助。 Best regards. 最好的祝福。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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