如何使用SpaTemplates在Visual Studio 2017中为ASP.NET Core Angular 2应用程序添加字体真棒

问题描述 投票:3回答:2

我在Visual Studio 2017中使用单页应用程序模板来创建Angular 2应用程序。

dotnet new --install Microsoft.AspNetCore.SpaTemplates::*

然后创建这样的应用程序:

dotnet new angular

将第三方库(如字体awesome)导入Angular 2应用程序的推荐方法是什么?

angular asp.net-core font-awesome visual-studio-2017
2个回答
3
投票

信用original post

在使用dotnet new angular创建SPA项目之后,这适用于.NET Core 2:

  1. 转到项目的根目录并安装包:npm install font-awesome --save。您现在应该在package.json依赖项中看到它。
  2. 之后转到webpack.config.vendor.js并将字体awesome添加到非树可振模块下的数组中: const nonTreeShakableModules = ['bootstrap','bootstrap / dist / css / bootstrap.css','es6-promise','es6-shim','event-source-polyfill','font-awesome / css / font-awesome .css','jquery',];
  3. 现在我们需要告诉webpack我们添加了这个新包。因此,如果你还没有这样做,那么在使用npm install --save-dev npm-install-webpack-plugin在项目的根目录中安装它之前。
  4. 最后,在项目的根目录中运行此命令:webpack --config webpack.config.vendor.js

5
投票

我正在寻找完全相同的东西。

终于找到了答案:http://blog.stevensanderson.com/2016/10/04/angular2-template-for-visual-studio/

别忘了做:

webpack --config webpack.config.vendor.js

如上所述,还要确保在执行此操作时也重新启动ASP.NET Core管道。

问候

© www.soinside.com 2019 - 2024. All rights reserved.