Angular2 CLI与ng build和auto reload有什么不同?

时间:2016-07-07 15:15:20

标签: typescript angular angular2-cli

  

当我ng build时,我的/dist/vendor文件夹中有一组文件。

enter image description here

  

但是当使用重新加载浏览器页面的魔术脚本检测到文件更改时,以及他们执行的其他魔术时,我的dist/vendor文件夹会以某种方式“搞砸”。看:

enter image description here

这是我应该对此负责的angular-cli-build.js,但我不知道如何:

var Angular2App = require('angular-cli/lib/broccoli/angular2-app');

module.exports = function(defaults) {
  return new Angular2App(defaults, {
    vendorNpmFiles: [
      'systemjs/dist/system-polyfills.js',
      'systemjs/dist/system.src.js',
      'zone.js/dist/**/*.+(js|js.map)',
      'es6-shim/es6-shim.js',
      'reflect-metadata/**/*.+(js|js.map)',
      'rxjs/**/*.+(js|js.map)',
      '@angular/**/*.+(js|js.map)',
      // above are the existing entries
      // below are the AngularFire entries
      'angularfire2/**/*.js',
      'firebase/*.js',
      '@angular2-material/**/*.js',   
      'ng2-uploader/*.js',   
      'underscore/underscore.js',   
      'primeng/**/*.js',
      'primeui/**/*.*'
    ]
  });
};

这是package.json:

{
  "name": "test",
  "version": "1.0.0",
  "license": "MIT",
  "angular-cli": {},
  "scripts": {
    "start": "ng serve",
    "postinstall": "typings install",
    "lint": "tslint \"src/**/*.ts\"",
    "test": "ng test",
    "pree2e": "webdriver-manager update",
    "e2e": "protractor"
  },
  "private": true,
  "dependencies": {
    "@angular/common": "2.0.0-rc.1",
    "@angular/compiler": "2.0.0-rc.1",
    "@angular/core": "2.0.0-rc.1",
    "@angular/http": "2.0.0-rc.1",
    "@angular/platform-browser": "2.0.0-rc.1",
    "@angular/platform-browser-dynamic": "2.0.0-rc.1",
    "@angular/router": "3.0.0-alpha.3",
    "@angular2-material/button": "^2.0.0-alpha.6",
    "@angular2-material/checkbox": "^2.0.0-alpha.6",
    "@angular2-material/core": "^2.0.0-alpha.6",
    "angularfire2": "^2.0.0-beta.2",
    "es6-shim": "0.35.1",
    "firebase": "^3.0.5",
    "ng2-slim-loading-bar": "^1.2.3",
    "primeng": "^1.0.0-beta.9",
    "primeui": "^4.1.12",
    "reflect-metadata": "0.1.3",
    "rxjs": "5.0.0-beta.6",
    "systemjs": "0.19.26",
    "underscore": "^1.8.3",
    "zone.js": "0.6.12"
  },
  "devDependencies": {
    "angular-cli": "1.0.0-beta.6",
    "codelyzer": "0.0.20",
    "ember-cli-inject-live-reload": "1.4.0",
    "jasmine-core": "2.4.1",
    "jasmine-spec-reporter": "2.5.0",
    "karma": "0.13.22",
    "karma-chrome-launcher": "0.2.3",
    "karma-jasmine": "0.3.8",
    "protractor": "3.3.0",
    "ts-node": "0.5.5",
    "tslint": "3.11.0",
    "typescript": "1.8.10",
    "typings": "0.8.1"
  }
}

这搞乱了我的第三方图书馆。为什么会这样?

1 个答案:

答案 0 :(得分:1)

一个简单的答案是,当您执行ng build时,您的服务器仍在运行,如果您停止服务器并执行ng build然后运行ng serve,则文件应保留在供应商中文件夹中。