Hook into angular-cli build watch

后端 未结 5 543
南方客
南方客 2020-12-06 10:06

I\'d like to to know if it is possible to hook into angular-cli\'s build/watch command:

ng build /w

which generates files and dr

5条回答
  •  不知归路
    2020-12-06 10:42

    I managed to achieve what I wanted with parallel tasks, copyfiles and npm watch:

    npm dev dependencies:

    "npm-watch": "^0.1.8",
    "parallelshell": "^2.0.0",
    "copyfiles": "^1.2.0",
    

    package.json snippet:

    "watch": {
        "copy-files": "dist/*.js"
      },
      "scripts": {
        "ng": "ng",
        "start": "ng serve",
        "lint": "tslint \"src/**/*.ts\" --project src/tsconfig.json --type-check && tslint \"e2e/**/*.ts\" --project e2e/tsconfig.json --type-check",
        "test": "ng test",
        "pree2e": "webdriver-manager update --standalone false --gecko false",
        "e2e": "protractor",
        "watch": "npm-watch",
        "copy-files": "copyfiles src/** dist/** ../angular",
        "ng-build": "ng build -w",
        "build": "parallelshell \"ng build\" \"npm run watch\" "
      },
    

    Then

    npm run build

    FWIW the watch config is saying, if anything in dist/*.js changes, run the "copy-files" npm script...

提交回复
热议问题