gpt4 book ai didi

Angular 6 构建无法加载资源

转载 作者:行者123 更新时间:2023-12-03 23:12:56 26 4
gpt4 key购买 nike

我正在尝试使用命令 ng build --prod 构建我的应用程序但是当我尝试在 dist 中加载 index.html 文件时文件夹,我收到以下错误:

styles.76a1111….css:1 Failed to load resource: the server responded with a status of 404 (Not Found)
runtime.06daa30….js:1 Failed to load resource: the server responded with a status of 404 (Not Found)
polyfills.f6ae3e8….js:1 Failed to load resource: the server responded with a status of 404 (Not Found)
scripts.f11023c….js:1 Failed to load resource: the server responded with a status of 404 (Not Found)
main.4ee5dbf….js:1 Failed to load resource: the server responded with a status of 404 (Not Found)
styles.76a1111….css:1 Failed to load resource: the server responded with a status of 404 (Not Found)

index.html 文件我有以下内容:
<base href="/">

angular.json 文件
{
"$schema": "./node_modules/@angular/cli/lib/config/schema.json",
"version": 1,
"newProjectRoot": "projects",
"projects": {
"digital": {
"root": "",
"sourceRoot": "src",
"projectType": "application",
"prefix": "app",
"schematics": {},
"architect": {
"build": {
"builder": "@angular-devkit/build-angular:browser",
"options": {
"outputPath": "dist/digital",
"index": "src/index.html",
"main": "src/main.ts",
"polyfills": "src/polyfills.ts",
"tsConfig": "src/tsconfig.app.json",
"assets": [
"src/favicon.ico",
"src/assets"
],
"styles": [
"./node_modules/ngx-bootstrap/datepicker/bs-datepicker.css",
"./node_modules/@angular/material/prebuilt-themes/indigo-pink.css",
"./node_modules/bootstrap/dist/css/bootstrap.css",
"src/styles.scss"
],
"scripts": [
"./node_modules/jquery/dist/jquery.js",
"./node_modules/bootstrap/dist/js/bootstrap.bundle.js"
]
},
"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": true,
"extractLicenses": true,
"vendorChunk": false,
"buildOptimizer": true
}
}
},
"serve": {
"builder": "@angular-devkit/build-angular:dev-server",
"options": {
"browserTarget": "digital:build"
},
"configurations": {
"production": {
"browserTarget": "digital:build:production"
}
}
},
"extract-i18n": {
"builder": "@angular-devkit/build-angular:extract-i18n",
"options": {
"browserTarget": "digital: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": [
"./node_modules/bootstrap/dist/css/bootstrap.min.css",
"./node_modules/ngx-bootstrap/datepicker/bs-datepicker.css",
"./node_modules/@angular/material/prebuilt-themes/indigo-pink.css",
"src/styles.css"
],
"scripts": [],
"assets": [
"src/favicon.ico",
"src/assets"
]
}
},
"lint": {
"builder": "@angular-devkit/build-angular:tslint",
"options": {
"tsConfig": [
"src/tsconfig.app.json",
"src/tsconfig.spec.json"
],
"exclude": [
"**/node_modules/**"
]
}
}
}
},
"wedigital-e2e": {
"root": "e2e/",
"projectType": "application",
"architect": {
"e2e": {
"builder": "@angular-devkit/build-angular:protractor",
"options": {
"protractorConfig": "e2e/protractor.conf.js",
"devServerTarget": "digital:serve"
},
"configurations": {
"production": {
"devServerTarget": "digital:serve:production"
}
}
},
"lint": {
"builder": "@angular-devkit/build-angular:tslint",
"options": {
"tsConfig": "e2e/tsconfig.e2e.json",
"exclude": [
"**/node_modules/**"
]
}
}
}
}
},
"defaultProject": "digital",
"schematics": {
"@schematics/angular:component": {
"styleext": "scss"
}
}
}

其他信息:
Angular CLI: 6.2.7
Node: 8.10.0
OS: darwin x64
Angular: 6.1.10
dist 中的文件文件夹
3rdpartylicenses.txt
assets
favicon.ico
index.html
main.4ee5dbfc414143867b55.js
polyfills.f6ae3e8b63939c618130.js
runtime.06daa30a2963fa413676.js
scripts.f11023cbae55e24a4eeb.js
styles.76a1111b5a6844e3fc2b.css

最佳答案

您需要更改<base href="/"><base href="./">

关于Angular 6 构建无法加载资源,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/53698413/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com