Здание angular библиотека в н.г. - PullRequest
1 голос
/ 15 февраля 2020

Я борюсь с развитием моей angular библиотеки. Прежде всего, я создаю библиотеку angular 8 (текущая Cli версия 9), и я хочу вживую увидеть изменения кода моей библиотеки, пока я обслуживаю демонстрационное приложение, в котором я использую эту библиотеку.

Текущее поведение: Когда я делаю изменения в исходном коде библиотеки, демо-приложение angular перезагружается, но я не вижу каких-либо изменений, которые бы оказали влияние. Такое поведение в основном применялось с изменениями css, а не каждый раз для файла .ts.

Ожидаемое поведение: чтобы увидеть все изменения, которые я делаю в исходном коде библиотеки.

Текущий angular. json file

    {
  "$schema": "./node_modules/@angular/cli/lib/config/schema.json",
  "version": 1,
  "newProjectRoot": "projects",
  "projects": {
    "bDataTableDemo": {
      "projectType": "application",
      "schematics": {
        "@schematics/angular:component": {
          "style": "scss"
        }
      },
      "root": "",
      "sourceRoot": "src",
      "prefix": "app",
      "architect": {
        "build": {
          "builder": "@angular-devkit/build-angular:browser",
          "options": {
            "outputPath": "dist/bDataTableDemo",
            "index": "src/index.html",
            "main": "src/main.ts",
            "polyfills": "src/polyfills.ts",
            "tsConfig": "tsconfig.app.json",
            "aot": false,
            "assets": [
              "src/favicon.ico",
              "src/assets"
            ],
            "styles": [
              "node_modules/bootstrap/dist/css/bootstrap.min.css",
              "src/styles.scss"
            ],
            "scripts": [
              "node_modules/jquery/dist/jquery.min.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,
              "budgets": [
                {
                  "type": "initial",
                  "maximumWarning": "2mb",
                  "maximumError": "5mb"
                },
                {
                  "type": "anyComponentStyle",
                  "maximumWarning": "6kb",
                  "maximumError": "10kb"
                }
              ]
            }
          }
        },
        "serve": {
          "builder": "@angular-devkit/build-angular:dev-server",
          "options": {
            "browserTarget": "bDataTableDemo:build"
          },
          "configurations": {
            "production": {
              "browserTarget": "bDataTableDemo:build:production"
            }
          }
        },
        "extract-i18n": {
          "builder": "@angular-devkit/build-angular:extract-i18n",
          "options": {
            "browserTarget": "bDataTableDemo: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": [
              "src/styles.scss"
            ],
            "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": "bDataTableDemo:serve"
          },
          "configurations": {
            "production": {
              "devServerTarget": "bDataTableDemo:serve:production"
            }
          }
        }
      }
    },
    "ng-bootstrap-table": {
      "projectType": "library",
      "root": "projects/ng-bootstrap-table",
      "sourceRoot": "projects/ng-bootstrap-table/src",
      "prefix": "lib",
      "architect": {
        "build": {
          "builder": "@angular-devkit/build-ng-packagr:build",
          "options": {
            "tsConfig": "projects/ng-bootstrap-table/tsconfig.lib.json",
            "project": "projects/ng-bootstrap-table/ng-package.json"
          }
        },
        "test": {
          "builder": "@angular-devkit/build-angular:karma",
          "options": {
            "main": "projects/ng-bootstrap-table/src/test.ts",
            "tsConfig": "projects/ng-bootstrap-table/tsconfig.spec.json",
            "karmaConfig": "projects/ng-bootstrap-table/karma.conf.js"
          }
        },
        "lint": {
          "builder": "@angular-devkit/build-angular:tslint",
          "options": {
            "tsConfig": [
              "projects/ng-bootstrap-table/tsconfig.lib.json",
              "projects/ng-bootstrap-table/tsconfig.spec.json"
            ],
            "exclude": [
              "**/node_modules/**"
            ]
          }
        }
      }
    }
  },
  "defaultProject": "bDataTableDemo"
}

И мой tsconfig. json file

{
  "compileOnSave": false,
  "compilerOptions": {
    "baseUrl": "./",
    "outDir": "./dist/out-tsc",
    "sourceMap": true,
    "declaration": false,
    "downlevelIteration": true,
    "experimentalDecorators": true,
    "module": "esnext",
    "moduleResolution": "node",
    "importHelpers": true,
    "target": "es2015",
    "typeRoots": [
      "node_modules/@types"
    ],
    "lib": [
      "es2018",
      "dom"
    ],
    "paths": {
      "ng-bootstrap-table": [
        "dist/ng-bootstrap-table"
      ],
      "ng-bootstrap-table/*": [
        "dist/ng-bootstrap-table/*"
      ]
    }
  },
  "angularCompilerOptions": {
    "fullTemplateTypeCheck": true,
    "strictInjectionParameters": true
  }
}

Что я должен изменить, чтобы иметь ожидаемое поведение?

PS Я новичок в angular библиотеках, поэтому пока не могу найти решение.

Заранее спасибо !!

1 Ответ

0 голосов
/ 15 февраля 2020

Вы должны отредактировать пути в tsconfig, чтобы они указывали на index.ts вашей библиотеки вместо dist / - это встроенный артефакт, сгенерированный с помощью ng build my-library:

"my-library" : [ "libs/my-library/index.ts" ]
Добро пожаловать на сайт PullRequest, где вы можете задавать вопросы и получать ответы от других членов сообщества.
...