我只是将我的项目从7号角更新到8号角,出于某种原因,当我构建要生产的项目并将其放置到服务器中时,我的项目图标和字体都消失了,当我检查“网络”标签时,我看到了这个:
在检查请求的url之后,我发现基本路径不在资产的url中,我该怎么做。
这是我的angular.json文件
angular.json
{
"$schema": "./node_modules/@angular/cli/lib/config/schema.json",
"version": 1,
"newProjectRoot": "projects",
"projects": {
"HyPE4PM": {
"root": "",
"sourceRoot": "src",
"projectType": "application",
"prefix": "app",
"schematics": {},
"architect": {
"build": {
"builder": "@angular-devkit/build-angular:browser",
"options": {
"outputPath": "dist",
"index": "src/index.html",
"main": "src/main.ts",
"polyfills": "src/polyfills.ts",
"tsConfig": "src/tsconfig.app.json",
"showCircularDependencies": false,
"assets": [
{
"glob": "**/*",
"input": "./src/meta/",
"output": "./meta/"
},
{
"glob": "**/*",
"input": "./src/assets/images/",
"output": "./assets/images/"
},
{
"glob": "**/*",
"input": "./src/assets/fonts/",
"output": "./assets/fonts/"
}
],
"lazyModules": ["src/app/modules/lazy/burndown.module"],
"styles": ["src/styles/bootstrap-reboot.css", "src/styles/bootstrap.css", "src/styles/icomoon.scss", "src/styles/styles.scss", "src/styles/material-theme.scss", "src/styles/quill.scss", "src/styles/quill-bubble-theme.scss"],
"scripts": []
},
"configurations": {
"dev": {},
"dev4Prod": {
"baseHref": "/niku/custom/backlogBoard/"
},
"production": {
"fileReplacements": [
{
"replace": "src/environments/environment.ts",
"with": "src/environments/environment.prod.ts"
}
],
"aot": true,
"baseHref": "/niku/custom/backlogBoard/",
"buildOptimizer": true,
"extractCss": true,
"extractLicenses": true,
"namedChunks": true,
"optimization": true,
"outputHashing": "all",
"sourceMap": false,
"vendorChunk": true,
"budgets": [
{
"type": "initial",
"maximumWarning": "2mb",
"maximumError": "5mb"
}
]
}
}
},
"serve": {
"builder": "@angular-devkit/build-angular:dev-server",
"options": {
"port": 3000,
"browserTarget": "HyPE4PM:build"
},
"configurations": {
"production": {
"browserTarget": "HyPE4PM:build:production"
}
}
},
"extract-i18n": {
"builder": "@angular-devkit/build-angular:extract-i18n",
"options": {
"browserTarget": "XDPM:build"
}
},
"test": {
"builder": "@angular-devkit/build-angular:karma",
"configurations": {
"dev": {
"karmaConfig": "src/karma.conf.js"
},
"production": {
"karmaConfig": "src/karma-prod.conf.js"
}
},
"options": {
"main": "src/test.ts",
"polyfills": "src/polyfills.ts",
"tsConfig": "src/tsconfig.spec.json",
"styles": ["src/styles/styles.scss"],
"scripts": [],
"assets": ["src/assets"]
}
},
"lint": {
"builder": "@angular-devkit/build-angular:tslint",
"options": {
"tsConfig": ["src/tsconfig.app.json", "src/tsconfig.spec.json"],
"exclude": ["**/node_modules/**"]
}
}
}
},
"HyPE4PM-e2e": {
"root": "e2e/",
"projectType": "application",
"architect": {
"e2e": {
"builder": "@angular-devkit/build-angular:protractor",
"options": {
"protractorConfig": "e2e/protractor.conf.js",
"devServerTarget": "XDPM:serve"
},
"configurations": {
"production": {
"devServerTarget": "XDPM:serve:production"
}
}
},
"lint": {
"builder": "@angular-devkit/build-angular:tslint",
"options": {
"tsConfig": "e2e/tsconfig.e2e.json",
"exclude": ["**/node_modules/**"]
}
}
}
}
},
"defaultProject": "XDPM",
"schematics": {
"@schematics/angular:component": {
"styleext": "scss"
}
}
}
我需要添加"/niku/custom/backlogBoard/"
的this.is这是基本路径,现在对字体的请求在应该为https://www.dev08.com:8080/assets/fonts/icomoon.tff
的情况下看起来像这个https://www.dev08.com:8080/niku/custom/backlogBoard/assets/fonts/icomoon.tff
。
答案 0 :(得分:0)
尝试在您的应用模块中添加基本href ...:
import {Component, NgModule} from '@angular/core';
import {APP_BASE_HREF} from '@angular/common';
@NgModule({
providers: [{provide: APP_BASE_HREF, useValue: '/niku/custom/backlogBoard'}]
})
class AppModule {}