Angular-CLI外部JS库未正确加载

时间:2017-03-06 21:48:02

标签: angular angular-cli

我有以下package.json:

{
  "name": "website",
  "version": "1.0.0",
  "license": "Wrapbootstrap",
  "angular-cli": {},
  "scripts": {
    "start": "ng serve",
    "prod": "ng build -prod",
    "lint": "tslint \"src/**/*.ts\"",
    "test": "ng test",
    "pree2e": "webdriver-manager update",
    "e2e": "protractor"
  },
  "private": true,
  "dependencies": {
    "@angular/common": "^2.3.1",
    "@angular/compiler": "^2.3.1",
    "@angular/core": "^2.3.1",
    "@angular/forms": "^2.3.1",
    "@angular/http": "^2.3.1",
    "@angular/platform-browser": "^2.3.1",
    "@angular/platform-browser-dynamic": "^2.3.1",
    "@angular/router": "^3.3.1",
    "core-js": "^2.4.1",
    "marked": "0.3.6",
    "rxjs": "^5.0.1",
    "ts-helpers": "^1.1.1",
    "zone.js": "^0.7.2",
    "bootstrap": "3.3.7",
    "jquery": "2.1.4",
    "jquery-sticky": "1.0.4",
    "jquery.easing": "1.3",
    "owl.carousel": "2.2.0",
    "magnific-popup": "1.1.0"
  },
  "devDependencies": {
    "@types/jasmine": "2.2.30",
    "@types/marked": "0.0.28",
    "angular-cli": "^1.0.0-beta.28",
    "codelyzer": "1.0.0-beta.1",
    "jasmine-core": "2.5.2",
    "jasmine-spec-reporter": "2.5.0",
    "karma": "1.2.0",
    "karma-chrome-launcher": "^2.0.0",
    "karma-cli": "^1.0.1",
    "karma-jasmine": "^1.0.2",
    "karma-remap-istanbul": "^0.2.1",
    "protractor": "4.0.9",
    "ts-node": "1.2.1",
    "tslint": "^4.3.0",
    "typescript": "2.0.3"
  }
}

以及以下angular-cli.json:

{
  "project": {
    "version": "1.0.0",
    "name": "website"
  },
  "apps": [
    {
      "root": "src",
      "outDir": "../webapp",
      "assets": [
        "assets",
        "favicon.ico"
      ],
      "index": "index.html",
      "main": "main.ts",
      "test": "test.ts",
      "tsconfig": "tsconfig.json",
      "prefix": "app",
      "mobile": true,
      "styles": [
        "../node_modules/bootstrap/dist/css/bootstrap.min.css",
        "assets/styles/themify-icons.css",
        "../node_modules/owl.carousel/dist/assets/owl.carousel.min.css",
        "../node_modules/owl.carousel/dist/assets/owl.theme.default.min.css",
        "../node_modules/magnific-popup/dist/magnific-popup.css",
        "assets/styles/styles.css"
      ],
      "scripts": [
        "../node_modules/jquery/dist/jquery.min.js",
        "../node_modules/bootstrap/dist/js/bootstrap.min.js",
        "../node_modules/jquery-sticky/jquery.sticky.js",
        "../node_modules/jquery.easing/jquery.easing.min.js",
        "../node_modules/owl.carousel/dist/owl.carousel.min.js",
        "../node_modules/magnific-popup/dist/jquery.magnific-popup.min.js",
        "assets/js/app.js"
      ],
      "environments": {
        "source": "environments/environment.ts",
        "dev": "environments/environment.ts",
        "prod": "environments/environment.prod.ts"
      }
    }
  ],
  "addons": [],
  "packages": [],
  "e2e": {
    "protractor": {
      "config": "./protractor.conf.js"
    }
  },
  "test": {
    "karma": {
      "config": "./karma.conf.js"
    }
  },
  "defaults": {
    "styleExt": "css",
    "prefixInterfaces": false
  }
}

assets / js / app.js 捆绑在脚本包Javascript中,并在主包之前添加到index.html中,如下所示:

<script type="text/javascript" src="inline.c4f83930cdfce013fa53.bundle.js"></script>
<script type="text/javascript" src="scripts.87a08269b31e920c5ae1.bundle.js"></script>
<script type="text/javascript" src="vendor.1f7ce844059add8c0d05.bundle.js"></script>
<script type="text/javascript" src="main.d1e0312785d030472370.bundle.js"></script>

是否可以在主捆绑后捆绑脚本? 我需要这个,因为外部资产/ js / app.js需要在其他所有内容加载后加载。

感谢。

0 个答案:

没有答案