jspm安装到另一个文件夹

时间:2016-01-24 17:38:33

标签: jspm

我希望jspm安装到不同的目录(wwwroot),因此它需要将它的config.js和jspm_packages文件夹放在那里。但我希望config.js不包含wwwroot,因为当你在网站上时,就是root(),当它查找wwwroot \ jspm_packages时,它无法找到它们。有没有办法做到这一点?

的package.json

Warning: xxxxxxxxxxx

config.js

此文件由" json install"创建。命令,它是构建过程的一部分。

{
  "name": "angular2-aspnetcore-starter",
  "version": "1.0.0",
  "description": "Angular2 with Asp.net Core starter kit.",
  "scripts": {
    "test": "echo \"Error: no test specified\" && exit 1"
  },
  "author": "Ryan Langton",
  "license": "ISC",
  "jspm": {
    "directories": {
      "packages": "wwwroot/jspm_packages" // <- need wwwroot for jspm install
    },
    "configFile": "wwwroot/config.js",    // <- need wwwroot for jspm install
    "dependencies": {
      "angular2": "npm:angular2@2.0.0-beta.1",
      "angular2-polyfill": "npm:angular2-polyfill@^0.0.1",
      "es6-shim": "github:es-shims/es6-shim@^0.34.1",
      "reflect-metadata": "npm:reflect-metadata@0.1.2",
      "rxjs": "npm:rxjs@5.0.0-beta.0",
      "zonejs": "npm:zone.js@^0.5.10"
    },
    "devDependencies": {
      "babel": "npm:babel-core@^5.8.24",
      "babel-runtime": "npm:babel-runtime@^5.8.24",
      "core-js": "npm:core-js@^1.1.4"
    }
  },
  "devDependencies": {
    "angular2": "2.0.0-beta.1",
    "del": "^2.2.0",
    "es6-promise": "^3.0.2",
    "es6-shim": "^0.33.13",
    "gulp": "~3.9.0",
    "gulp-typescript": "~2.10.0",
    "gulp-watch": "~4.3.5",
    "jspm": "^0.16.24",
    "reflect-metadata": "0.1.2",
    "rxjs": "5.0.0-beta.0",
    "zone.js": "^0.5.10"
  }
}

1 个答案:

答案 0 :(得分:0)

几种选择。您的所有组件/自定义JS是否也在wwwroot中?如果是这样,我只是将jspm安装到该目录,然后jspm将只查看当前的dir ...这将是本地的wwwroot,但在生产中它只会查看你的网站的根目录。

第二个选项,也建议因为它更快,将使用jspm bundle捆绑所有依赖项,然后JSPM将能够正确地找到它们。这只是捆绑所有deps到bundle.js,把它放在wwwroot中,然后在加载system.js之后在你的索引文件中执行:

System.import('./bundle.js').then( () => { ... }