How to add font awesome to ASP.NET Core Angular 2 application in Visual Studio 2017 with SpaTemplates

前端 未结 2 1946
梦毁少年i
梦毁少年i 2020-12-21 05:16

I am using the Single Page Application Template in Visual Studio 2017 in order to create an Angular 2 application.

dotnet new --install Microsoft.AspNetCore.         


        
2条回答
  •  挽巷
    挽巷 (楼主)
    2020-12-21 05:36

    Credit original post

    This is for .NET Core 2, after you create a SPA Project using dotnet new angular:

    1. Go to the root of the project and install the package: npm install font-awesome --save. You should now see it in package.json dependencies.

    2. After that go to webpack.config.vendor.js and add font awesome to the array under non tree shakable modules:

      const nonTreeShakableModules = [ 'bootstrap', 'bootstrap/dist/css/bootstrap.css', 'es6-promise', 'es6-shim', 'event-source-polyfill', 'font-awesome/css/font-awesome.css', 'jquery', ];

    3. Now we need to tell the webpack that we added this new package. So if you haven't done so before install this in the root of project with npm install --save-dev npm-install-webpack-plugin.

    4. Finally, run this command in the root of project: webpack --config webpack.config.vendor.js

提交回复
热议问题