我正在整理Angular应用程序并尝试部署它。过去,我一直使用“ ng serve”来运行该应用程序。它已经并且将继续正常运行。当我使用ng build --prod时,我的dist文件夹中充满了似乎是该应用程序的一个非常过时的版本。它缺少我的应用程序文件夹中的所有文件。查看Angular.Json文件,我可以看到dist文件夹中正在创建的很多东西都来自它。我想知道是否将丢失的文件夹添加到Json文件中,以便在构建中使用它们。但是,考虑到项目中有多少个第三方文件(例如Kendo组件和CSS文件),这似乎不太可能起作用。 也许我误会了一些东西。
我应该添加:我添加了“ src / app”,现在包括了我的所有组件,但是包含我所有css(来自bootstrap和kendo)的node_module文件夹不起作用。
我忍不住想起了我忽略使用的Angular.Json文件的一些自动更新。
{
"$schema": "./node_modules/@angular/cli/lib/config/schema.json",
"version": 1,
"newProjectRoot": "projects",
"projects": {
"Views": {
"projectType": "application",
"schematics": {},
"root": "",
"sourceRoot": "src",
"prefix": "pm",
"architect": {
"build": {
"builder": "@angular-devkit/build-angular:browser",
"options": {
"outputPath": "dist/Views",
"index": "src/index.html",
"main": "src/main.ts",
"polyfills": "src/polyfills.ts",
"tsConfig": "tsconfig.app.json",
"aot": false,
"assets": [
"src/favicon.ico",
"src/assets",
"src/api"
],
"styles": [
{
"input": "node_modules/@progress/kendo-theme-default/dist/all.css"
},
"src/styles.css"
],
"scripts": []
},
"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,
"budgets": [
{
"type": "initial",
"maximumWarning": "2mb",
"maximumError": "5mb"
}
]
}
}
},
"serve": {
"builder": "@angular-devkit/build-angular:dev-server",
"options": {
"browserTarget": "APM:build",
"proxyConfig": "proxy.conf.json"
},
"configurations": {
"production": {
"browserTarget": "APM:build:production"
}
}
},
"extract-i18n": {
"builder": "@angular-devkit/build-angular:extract-i18n",
"options": {
"browserTarget": "APM:build"
}
},
"test": {
"builder": "@angular-devkit/build-angular:karma",
"options": {
"main": "src/test.ts",
"polyfills": "src/polyfills.ts",
"tsConfig": "tsconfig.spec.json",
"karmaConfig": "karma.conf.js",
"assets": [
"src/favicon.ico",
"src/assets"
],
"styles": [
{
"input": "node_modules/@progress/kendo-theme-default/dist/all.css"
},
"src/styles.css"
],
"scripts": []
}
},
"lint": {
"builder": "@angular-devkit/build-angular:tslint",
"options": {
"tsConfig": [
"tsconfig.app.json",
"tsconfig.spec.json",
"e2e/tsconfig.json"
],
"exclude": [
"**/node_modules/**"
]
}
},
"e2e": {
"builder": "@angular-devkit/build-angular:protractor",
"options": {
"protractorConfig": "e2e/protractor.conf.js",
"devServerTarget": "APM:serve"
},
"configurations": {
"production": {
"devServerTarget": "APM:serve:production"
}
}
}
}
}
},
"defaultProject": "APM"
}
答案 0 :(得分:0)
文件的输出不在dist文件夹中,而是在dist文件夹中的Views文件夹中。
“ dist / Views”
您可以在此处查看。
如果仍然不清楚,您可以删除dist文件夹中的所有内容,然后再次运行prod构建
答案 1 :(得分:0)
解决方案是: 1.创建一个web.config文件,例如:
<?xml version="1.0" encoding="UTF-8"?>
<configuration>
<system.webServer>
<defaultDocument>
<files>
<add value="index.html" />
</files>
</defaultDocument>
</system.webServer>
</configuration>
然后进入Index.html文件并更改<base href="/"> to <base href="./">.