【问题标题】:How to change path for build project in angular?如何以角度更改构建项目的路径?
【发布时间】:2019-01-08 15:31:03
【问题描述】:

这里我的项目名称是angulardemo,所以我使用这个命令构建项目

ng build --prod --base-href /angulardemo/

所以这个命令构建项目并创建 dist 文件夹并在 dist 文件夹内创建 angulardemo 命名文件夹和在 angulardemo 文件夹内创建以下文件

3rdpartylicenses.txt
favicon.ico
index.html
main.95e7fd4eb2e659e65554.js
polyfills.1ef83d22ada557f4a131.js
runtime.ec2944dd8b20ec099bf3.js
styles.3ff695c00d717f2d2a11.css

但我想直接在 dist 文件夹中创建这些文件不想在 dist 文件夹中创建 angulardemo 文件夹怎么可能?

【问题讨论】:

  • 您必须在 angular.json 中设置输出目录。您可以在此处编辑此选项:项目->您的项目名称->架构师->构建->选项-> outputPath:“dist”

标签: build angular-cli


【解决方案1】:

您可以在 angular.json 中更改输出路径

{
 "projects": {
   "my-app-name": {
    "architect": {
     "options": {
       "outputPath": "dist", <-----here

【讨论】:

    【解决方案2】:

    使用新版本的 angular (v6+)angular CLI,它默认位于 dist directory/yourproject 内。

    虽然您可以在angular.json 中更改构建选项

    "architect": {
            "build": {
              "builder": "@angular-devkit/build-angular:browser",
              "options": {
                "outputPath": "dist",
                "index": "src/index.html",
                "main": "src/main.ts",
    

    【讨论】:

    • 你应该看到 assetsstyles 在 angular.json 中是如何被引用的。修复它们,清理你的 dist 并重新构建它。你能分享你的 angular.json 吗?
    • 检查您的tsconfig.json outDir。看看是不是 "outDir": "../../dist/out-tsc",
    猜你喜欢
    • 2021-08-17
    • 1970-01-01
    • 1970-01-01
    • 2020-03-07
    • 1970-01-01
    • 2015-06-06
    • 2019-04-04
    • 1970-01-01
    • 2021-06-13
    相关资源
    最近更新 更多