在 apache 服务器上部署 angular 个应用程序

Deploy angular app on apache server

为了在服务器上部署我的 angular 应用程序,我 运行 使用以下命令:ng build --prod。但是在我得到的 dist 文件夹中,我没有 index.html 文件。我想知道复制和粘贴我拥有的 index.html 文件是否是最佳做法,或者我是否缺少其他内容。

angular-cli.json

{
  "project": {
    "version": "1.0.0-beta.28.3",
    "name": "main"
  },
  "apps": [
    {
      "root": "src",
      "outDir": "../../target/frontend",
      "assets": [
        "assets",
        "favicon.ico"
      ],
      "index": "index.html",
      "main": "main.ts",
      "polyfills": "polyfills.ts",
      "test": "test.ts",
      "tsconfig": "tsconfig.json",
      "prefix": "app",
      "styles": [
        "styles.css"
      ],
      "scripts": [],
      "environmentSource": "environments/environment.ts",
      "environments": {
        "dev": "environments/environment.ts",
        "prod": "environments/environment.prod.ts"
      }
    }
  ],
  "e2e": {
    "protractor": {
      "config": "./protractor.conf.js"
    }
  },
  "lint": [
    {
      "files": "src/**/*.ts",
      "project": "src/tsconfig.json"
    },
    {
      "files": "e2e/**/*.ts",
      "project": "e2e/tsconfig.json"
    }
  ],
  "test": {
    "karma": {
      "config": "./karma.conf.js"
    }
  },
  "defaults": {
    "styleExt": "css",
    "prefixInterfaces": false,
    "inline": {
      "style": false,
      "template": false
    },
    "spec": {
      "class": false,
      "component": true,
      "directive": true,
      "module": false,
      "pipe": true,
      "service": true
    }
  }
}

这一行
"outDir": "../../target/frontend", 建议您的代码是在 target\frontend 文件夹中生成的,而不是在 dist 文件夹中生成的。如果你想把它改成dist。将该行更改为 "outDir": "dist", 来自 "outDir": "../../target/frontend",