[英]Convert existing asp.net core 2.1 angular app to Angular 6 and Angular CLI 6
I created an asp.net core 2.1 angular web app which is come with 5.2 Angular. 我创建了5.2 Angular附带的asp.net core 2.1 angular Web应用程序。 I would like to upgrade to angular 6 and Angular CLI 6. These are the steps I did:
我想升级到angular 6和Angular CLI6。这些是我做的步骤:
Not sure what other steps I am missing 不知道我还缺少什么其他步骤
Sample project link https://github.com/tkumark/WebApplication3 示例项目链接https://github.com/tkumark/WebApplication3
Update your angular.json to force extractCss on build and don't miss to add bootstrap as style dependency: 更新您的angular.json以强制在构建时进行extractCss ,不要错过添加bootstrap作为样式依赖项:
{
"$schema": "./node_modules/@angular/cli/lib/config/schema.json",
"version": 1,
"newProjectRoot": "projects",
"projects": {
"your-app": {
"root": "",
"sourceRoot": "src",
"projectType": "application",
"architect": {
"build": {
"builder": "@angular-devkit/build-angular:browser",
"options": {
"extractCss": true,
"styles": [
"src/styles.css",
"node_modules/bootstrap/dist/css/bootstrap.min.css"
],
Check the configuration section as well: 还要检查配置部分:
"configurations": {
"production": {
...
"extractCss": true
"debug": {
...
The angular.json schema can be found here : https://github.com/angular/angular-cli/wiki/angular-workspace 可以在这里找到angular.json模式: https : //github.com/angular/angular-cli/wiki/angular-workspace
You also need to check if the SPA static files root path match the out path of your angular.json : 您还需要检查SPA静态文件的根路径是否与angular.json的out路径匹配:
Startup.cs 启动文件
// In production, the Angular files will be served from this directory
services.AddSpaStaticFiles(configuration =>
{
configuration.RootPath = "ClientApp/dist";
});
angular.json angular.json
"outputPath": "dist",
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.