[英]not found file in server when build and uplaod project
i have a project in angular 9 and asp core 3.我在 angular 9 和 asp core 3 中有一个项目。
this is addres of site: http://mag-testcpl.astromap.ir/这是网站地址: http://mag-testcpl.astromap.ir/
and it show me this error:它告诉我这个错误:
http://mag-testcpl.astromap.ir/assets/vendors/global/toastr.css
and this is in my html:这是在我的 html 中:
<head>
<meta charset="utf-8">
<title>Astronomy Mag | Admin panel</title>
<base href="/app">
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="icon" type="image/x-icon" href="./assets/media/logos/favicon.png">
<link id="mainStyle" href="./assets/css/demo1/style.bundle.main.css" rel="stylesheet">
<link id="ltrStyle" href="./assets/css/demo1/style.bundle.css" rel="stylesheet">
<link id="rtlStyle" href="./assets/css/demo1/style.bundle.rtl.css" rel="stylesheet">
<link id="toaster" href="./assets/vendors/global/toastr.css" rel="stylesheet">
<style>
</style>
when i enter this url in brwoser http://mag-testcpl.astromap.ir/assets/vendors/global/toastr.css
it not show me any things but when i enter this url in by this http://mag-testcpl.astromap.ir/app/assets/vendors/global/toastr.css
when i enter this url in brwoser
http://mag-testcpl.astromap.ir/assets/vendors/global/toastr.css
it not show me any things but when i enter this url in by this http://mag-testcpl.astromap.ir/app/assets/vendors/global/toastr.css
add /app to url
将 /app 添加到 url
it's worked and show me file.它的工作,并显示我的文件。
i build the project with this command ng build --prod --base-href /app
我用这个命令构建项目
ng build --prod --base-href /app
how can i solve this problem?????我怎么解决这个问题?????
"architect": {
"build": {
"builder": "@angular-devkit/build-angular:browser",
"options": {
"outputPath": "dist/avastar",
"index": "src/index.html",
"main": "src/main.ts",
"polyfills": "src/polyfills.ts",
"tsConfig": "src/tsconfig.app.json",
"assets": [
"src/favicon.png",
"src/assets"
],
"styles": [
"src/styles.scss",
"./node_modules/quill/assets/snow.styl",
"./node_modules/quill/assets/core.styl",
"./node_modules/quill/assets/bubble.styl"
],
"scripts": [
"src/assets/vendors/global/vendors.bundle.js",
"src/assets/js/demo1/scripts.bundle.js"
],
"stylePreprocessorOptions": {
"includePaths": [
"src",
"src/stylings/",
"src/stylings/base/",
"src/stylings/kt-customs/"
]
},
"es5BrowserSupport": true
},
"configurations": {
"production": {
"fileReplacements": [
{
"replace": "src/environments/environment.ts",
"with": "src/environments/environment.prod.ts"
}
],
"optimization": true,
"outputHashing": "all",
"sourceMap": false,
"extractCss": true,
"namedChunks": false,
"aot": false,
"extractLicenses": true,
"vendorChunk": false,
"buildOptimizer": false,
"budgets": [
{
"type": "initial",
"maximumWarning": "5mb",
"maximumError": "10mb"
}
]
}
}
},
"serve": {
"builder": "@angular-devkit/build-angular:dev-server",
"options": {
"browserTarget": "avastar:build"
},
"configurations": {
"production": {
"browserTarget": "avastar:build:production"
}
}
},
"extract-i18n": {
"builder": "@angular-devkit/build-angular:extract-i18n",
"options": {
"browserTarget": "avastar:build"
}
},
"test": {
"builder": "@angular-devkit/build-angular:karma",
"options": {
"main": "src/test.ts",
"polyfills": "src/polyfills.ts",
"tsConfig": "src/tsconfig.spec.json",
"karmaConfig": "src/karma.conf.js",
"styles": [
"src/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/**"
]
}
}
}
Let's first understand what is base href我们先来了解一下什么是base href
if you wan to use different base paths for router and static assets.如果您想对路由器和 static 资产使用不同的基本路径。 Angular makes use of the base href to tell router how to compose navigation URLs.
Angular 使用基本 href 来告诉路由器如何编写导航 URL。 If your application exists at the root, then you can use / as the href value as shown.
如果您的应用程序存在于根目录,那么您可以使用 / 作为 href 值,如图所示。
<base href="/">
==> HTML <base href="/">
==> HTML
I wanted to use /users
as my application base for router and /public
as base for my assets.我想使用
/users
作为路由器的应用程序基础,并使用/public
作为我的资产的基础。 <base href="/users">
&& <link href="/public/styles.xxxx.bundle.css" rel="stylesheet"/>
<base href="/users">
&& <link href="/public/styles.xxxx.bundle.css" rel="stylesheet"/>
So you must use this command ng build -prod --base-href /users --deploy-url /public
所以你必须使用这个命令
ng build -prod --base-href /users --deploy-url /public
The answer is do you really need to append app
to your route?答案是你真的需要 append
app
到你的路线吗? if no just use ng build --prod
如果没有,只需使用
ng build --prod
Hope it helps希望能帮助到你
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.