虚拟目录的 Aurelia 捆绑问题

Aurelia bundling issue with virtual directory

更新

我找到了问题的根源,但我还是想不通。如果站点是 http://mysite/vd1/vd2/ 而不是 http://mysite/vd1/vd2(正确的站点有尾部斜杠),则一切都正确加载

原创

我正在尝试将我的第一个 aspnetcore aurelia-app 发布到虚拟目录 http://mysite/vd1/vd2 中的 IIS,其中 vd2(虚拟目录 2)是 aurelia-app 的主目录。但是,当浏览器尝试加载第一个包 aurelia.js 时,它正在查找 http://mysite/vd1/dist 而不是 vd2,后者 returns 是 404。我试图使路径相对,但是也许我错过了什么?感谢任何帮助,如果需要更多信息,请告诉我,因为我在追踪问题时遇到问题。

Index.cshtml

<div aurelia-app="main">
  <div class="splash">
    <div class="message">@ViewBag.AppTitle</div>
    <div class="fa fa-spinner fa-pulse fa-fw"></div>
  </div>

  <environment names="Development">
    <script src="~/jspm_packages/npm/bluebird@3.4.1/js/browser/bluebird.js"></script>
  </environment>
  <environment names="Staging,Production">
    <script src="~/jspm_packages/npm/bluebird@3.4.1/js/browser/bluebird.min.js"></script>
  </environment>

  <script src="~/jspm_packages/system.js"></script>

  <script src="~/config.js"></script>

  <script>
    System.import("aurelia-bootstrapper");
  </script>
</div>

bundle.js

var gulp = require('gulp');
var bundler = require('aurelia-bundler');
var bundles = require('../bundles.js');

var config = {
  force: true,
  baseURL: './wwwroot',
  configPath: './wwwroot/config.js',
  bundles: bundles.bundles
};

gulp.task('bundle', ['build'], function() {
  return bundler.bundle(config);
});

gulp.task('unbundle', function() {
  return bundler.unbundle(config);
});

bundles.js

module.exports = {
  "bundles": {
    "dist/app-build": {
      "includes": [
        "[**/*.js]",
        "**/*.html!text",
        "**/*.css!text"
      ],
      "options": {
        "inject": true,
        "minify": true,
        "depCache": true,
        "rev": false
      }
    },
    "dist/aurelia": {
      "includes": [
        "aurelia-framework",
        "aurelia-bootstrapper",
        "aurelia-fetch-client",
        "aurelia-router",
        "aurelia-animator-css",
        "aurelia-dialog",
        "aurelia-event-aggregator",
        "aurelia-templating-binding",
        "aurelia-polyfills",
        "aurelia-templating-resources",
        "aurelia-templating-router",
        "aurelia-loader-default",
        "aurelia-history-browser",
        "aurelia-logging-console",
        "aurelia-pal-browser",
        "aurelia-validation",
        "bootstrap",
        "bootstrap/css/bootstrap.min.css!text",
        "fetch",
        "jquery",
        "moment",
        "jquery-ui",
        "keymirror",
        "toastr"
      ],
      "options": {
        "inject": true,
        "minify": true,
        "depCache": false,
        "rev": false
      }
    }
  }
};

config.js

System.config({
  defaultJSExtensions: true,
  transpiler: false,
  paths: {
    "*": "dist/*",
    "github:*": "jspm_packages/github/*",
    "npm:*": "jspm_packages/npm/*"
  },
  map: {
    "aurelia-animator-css": "npm:aurelia-animator-css@1.0.0",
    "aurelia-bootstrapper": "npm:aurelia-bootstrapper@1.0.0",
    "aurelia-dialog": "npm:aurelia-dialog@1.0.0-beta.3.0.0",
    "aurelia-event-aggregator": "npm:aurelia-event-aggregator@1.0.0",
    "aurelia-fetch-client": "npm:aurelia-fetch-client@1.0.0",
    ...
  },
  bundles: {
    "aurelia.js": [
      "github:CodeSeven/toastr@2.1.3.js",
      "github:CodeSeven/toastr@2.1.3/build/toastr.css!github:systemjs/plugin-css@0.1.31.js",
      "github:CodeSeven/toastr@2.1.3/toastr.js",
      "github:components/jquery@3.1.1.js",
      "github:components/jquery@3.1.1/jquery.js",
      "github:components/jqueryui@1.12.1.js",
      "github:components/jqueryui@1.12.1/jquery-ui.js",
      "github:github/fetch@1.0.0.js",
      "github:github/fetch@1.0.0/fetch.js",
      "github:twbs/bootstrap@3.3.7.js",
      "github:twbs/bootstrap@3.3.7/css/bootstrap.min.css!github:systemjs/plugin-text@0.0.8.js",
      "github:twbs/bootstrap@3.3.7/js/bootstrap.js",
      "npm:aurelia-animator-css@1.0.0.js",
      "npm:aurelia-animator-css@1.0.0/aurelia-animator-css.js",
      "npm:aurelia-binding@1.0.9.js",
      "npm:aurelia-binding@1.0.9/aurelia-binding.js",
      "npm:aurelia-bootstrapper@1.0.0.js",
      "npm:aurelia-bootstrapper@1.0.0/aurelia-bootstrapper.js",
      "npm:aurelia-dependency-injection@1.2.0.js",
      "npm:aurelia-dependency-injection@1.2.0/aurelia-dependency-injection.js",
      "npm:aurelia-dialog@1.0.0-beta.3.0.0.js",
      "npm:aurelia-dialog@1.0.0-beta.3.0.0/ai-dialog-body.js",
      "npm:aurelia-dialog@1.0.0-beta.3.0.0/ai-dialog-footer.js",
      "npm:aurelia-dialog@1.0.0-beta.3.0.0/ai-dialog-header.js",
      "npm:aurelia-dialog@1.0.0-beta.3.0.0/ai-dialog.js",
      "npm:aurelia-dialog@1.0.0-beta.3.0.0/attach-focus.js",
      "npm:aurelia-dialog@1.0.0-beta.3.0.0/aurelia-dialog.js",
      "npm:aurelia-dialog@1.0.0-beta.3.0.0/dialog-configuration.js",
      "npm:aurelia-dialog@1.0.0-beta.3.0.0/dialog-controller.js",
      "npm:aurelia-dialog@1.0.0-beta.3.0.0/dialog-options.js",
      "npm:aurelia-dialog@1.0.0-beta.3.0.0/dialog-renderer.js",
      "npm:aurelia-dialog@1.0.0-beta.3.0.0/dialog-result.js",
      "npm:aurelia-dialog@1.0.0-beta.3.0.0/dialog-service.js",
      "npm:aurelia-dialog@1.0.0-beta.3.0.0/lifecycle.js",
      "npm:aurelia-dialog@1.0.0-beta.3.0.0/renderer.js",
      "npm:aurelia-event-aggregator@1.0.0.js",
      "npm:aurelia-event-aggregator@1.0.0/aurelia-event-aggregator.js",
      "npm:aurelia-fetch-client@1.0.0.js",
      "npm:aurelia-fetch-client@1.0.0/aurelia-fetch-client.js",
      "npm:aurelia-framework@1.0.7.js",
      "npm:aurelia-framework@1.0.7/aurelia-framework.js",
      "npm:aurelia-history-browser@1.0.0.js",
      "npm:aurelia-history-browser@1.0.0/aurelia-history-browser.js",
      "npm:aurelia-history@1.0.0.js",
      "npm:aurelia-history@1.0.0/aurelia-history.js",
      "npm:aurelia-loader-default@1.0.0.js",
      "npm:aurelia-loader-default@1.0.0/aurelia-loader-default.js",
      "npm:aurelia-loader@1.0.0.js",
      "npm:aurelia-loader@1.0.0/aurelia-loader.js",
      "npm:aurelia-logging-console@1.0.0.js",
      "npm:aurelia-logging-console@1.0.0/aurelia-logging-console.js",
      "npm:aurelia-logging@1.1.0.js",
      "npm:aurelia-logging@1.1.0/aurelia-logging.js",
      "npm:aurelia-metadata@1.0.2.js",
      "npm:aurelia-metadata@1.0.2/aurelia-metadata.js",
      "npm:aurelia-pal-browser@1.0.0.js",
      "npm:aurelia-pal-browser@1.0.0/aurelia-pal-browser.js",
      "npm:aurelia-pal@1.0.0.js",
      "npm:aurelia-pal@1.0.0/aurelia-pal.js",
      "npm:aurelia-path@1.1.1.js",
      "npm:aurelia-path@1.1.1/aurelia-path.js",
      "npm:aurelia-polyfills@1.0.0.js",
      "npm:aurelia-polyfills@1.0.0/aurelia-polyfills.js",
      "npm:aurelia-route-recognizer@1.0.0.js",
      "npm:aurelia-route-recognizer@1.0.0/aurelia-route-recognizer.js",
      "npm:aurelia-router@1.0.2.js",
      "npm:aurelia-router@1.0.2/aurelia-router.js",
      "npm:aurelia-task-queue@1.1.0.js",
      "npm:aurelia-task-queue@1.1.0/aurelia-task-queue.js",
      "npm:aurelia-templating-binding@1.0.0.js",
      "npm:aurelia-templating-binding@1.0.0/aurelia-templating-binding.js",
      "npm:aurelia-templating-resources@1.0.0.js",
      "npm:aurelia-templating-resources@1.0.0/abstract-repeater.js",
      "npm:aurelia-templating-resources@1.0.0/analyze-view-factory.js",
      "npm:aurelia-templating-resources@1.0.0/array-repeat-strategy.js",
      "npm:aurelia-templating-resources@1.0.0/aurelia-hide-style.js",
      "npm:aurelia-templating-resources@1.0.0/aurelia-templating-resources.js",
      "npm:aurelia-templating-resources@1.0.0/binding-mode-behaviors.js",
      "npm:aurelia-templating-resources@1.0.0/binding-signaler.js",
      "npm:aurelia-templating-resources@1.0.0/compose.js",
      "npm:aurelia-templating-resources@1.0.0/css-resource.js",
      "npm:aurelia-templating-resources@1.0.0/debounce-binding-behavior.js",
      "npm:aurelia-templating-resources@1.0.0/dynamic-element.js",
      "npm:aurelia-templating-resources@1.0.0/focus.js",
      "npm:aurelia-templating-resources@1.0.0/hide.js",
      "npm:aurelia-templating-resources@1.0.0/html-resource-plugin.js",
      "npm:aurelia-templating-resources@1.0.0/html-sanitizer.js",
      "npm:aurelia-templating-resources@1.0.0/if.js",
      "npm:aurelia-templating-resources@1.0.0/map-repeat-strategy.js",
      "npm:aurelia-templating-resources@1.0.0/null-repeat-strategy.js",
      "npm:aurelia-templating-resources@1.0.0/number-repeat-strategy.js",
      "npm:aurelia-templating-resources@1.0.0/repeat-strategy-locator.js",
      "npm:aurelia-templating-resources@1.0.0/repeat-utilities.js",
      "npm:aurelia-templating-resources@1.0.0/repeat.js",
      "npm:aurelia-templating-resources@1.0.0/replaceable.js",
      "npm:aurelia-templating-resources@1.0.0/sanitize-html.js",
      "npm:aurelia-templating-resources@1.0.0/set-repeat-strategy.js",
      "npm:aurelia-templating-resources@1.0.0/show.js",
      "npm:aurelia-templating-resources@1.0.0/signal-binding-behavior.js",
      "npm:aurelia-templating-resources@1.0.0/throttle-binding-behavior.js",
      "npm:aurelia-templating-resources@1.0.0/update-trigger-binding-behavior.js",
      "npm:aurelia-templating-resources@1.0.0/with.js",
      "npm:aurelia-templating-router@1.0.0.js",
      "npm:aurelia-templating-router@1.0.0/aurelia-templating-router.js",
      "npm:aurelia-templating-router@1.0.0/route-href.js",
      "npm:aurelia-templating-router@1.0.0/route-loader.js",
      "npm:aurelia-templating-router@1.0.0/router-view.js",
      "npm:aurelia-templating@1.1.2.js",
      "npm:aurelia-templating@1.1.2/aurelia-templating.js",
      "npm:aurelia-validation@0.13.1.js",
      "npm:aurelia-validation@0.13.1/aurelia-validation.js",
      "npm:aurelia-validation@0.13.1/implementation/rules.js",
      "npm:aurelia-validation@0.13.1/implementation/standard-validator.js",
      "npm:aurelia-validation@0.13.1/implementation/util.js",
      "npm:aurelia-validation@0.13.1/implementation/validation-messages.js",
      "npm:aurelia-validation@0.13.1/implementation/validation-parser.js",
      "npm:aurelia-validation@0.13.1/implementation/validation-rules.js",
      "npm:aurelia-validation@0.13.1/property-info.js",
      "npm:aurelia-validation@0.13.1/validate-binding-behavior-base.js",
      "npm:aurelia-validation@0.13.1/validate-binding-behavior.js",
      "npm:aurelia-validation@0.13.1/validate-trigger.js",
      "npm:aurelia-validation@0.13.1/validation-controller-factory.js",
      "npm:aurelia-validation@0.13.1/validation-controller.js",
      "npm:aurelia-validation@0.13.1/validation-error.js",
      "npm:aurelia-validation@0.13.1/validation-errors-custom-attribute.js",
      "npm:aurelia-validation@0.13.1/validation-renderer-custom-attribute.js",
      "npm:aurelia-validation@0.13.1/validator.js",
      "npm:jquery@2.2.4.js",
      "npm:jquery@2.2.4/dist/jquery.js",
      "npm:keymirror@0.1.1.js",
      "npm:keymirror@0.1.1/index.js",
      "npm:moment@2.14.1.js",
      "npm:moment@2.14.1/moment.js"
    ],
    "app-build.js": [
      "app.html!github:systemjs/plugin-text@0.0.8.js",
      "app.js",
      "assignments/assignment-store.js",
      "assignments/handler-list.html!github:systemjs/plugin-text@0.0.8.js",
      "assignments/handler-list.js",
      "assignments/notes.html!github:systemjs/plugin-text@0.0.8.js",
      "assignments/notes.js",
      "assignments/priority-flags.html!github:systemjs/plugin-text@0.0.8.js",
      "assignments/priority-flags.js",
      "configuration/http-client.js",
      "configuration/router.js",
      "configuration/toastr.js",
      "constants.js",
      "core/attachment-service.js",
      "core/http-interceptors.js",
      "core/logger.js",
      "core/resource-store.js",
      "core/store.js",
      "main.js",
      "register.js",
      "registration.html!github:systemjs/plugin-text@0.0.8.js",
      "registration.js",
      "requests/comment-store.js",
      "requests/comments.html!github:systemjs/plugin-text@0.0.8.js",
      "requests/comments.js",
      "requests/new-request.html!github:systemjs/plugin-text@0.0.8.js",
      "requests/new-request.js",
      "requests/request-detail.html!github:systemjs/plugin-text@0.0.8.js",
      "requests/request-detail.js",
      "requests/request-list.html!github:systemjs/plugin-text@0.0.8.js",
      "requests/request-list.js",
      "requests/request-store.js",
      "requests/request.html!github:systemjs/plugin-text@0.0.8.js",
      "requests/request.js",
      "requests/status-list.html!github:systemjs/plugin-text@0.0.8.js",
      "requests/status-list.js",
      "requests/view-list.html!github:systemjs/plugin-text@0.0.8.js",
      "requests/view-list.js",
      "resources/dialogs/validation-list.html!github:systemjs/plugin-text@0.0.8.js",
      "resources/dialogs/validation-list.js",
      "resources/elements/attachments.html!github:systemjs/plugin-text@0.0.8.js",
      "resources/elements/badge-list.html!github:systemjs/plugin-text@0.0.8.js",
      "resources/elements/badge-list.js",
      "resources/elements/color-flag.html!github:systemjs/plugin-text@0.0.8.js",
      "resources/elements/color-flag.js",
      "resources/elements/date-picker.html!github:systemjs/plugin-text@0.0.8.js",
      "resources/elements/date-picker.js",
      "resources/elements/drop-menu.html!github:systemjs/plugin-text@0.0.8.js",
      "resources/elements/menu-button.html!github:systemjs/plugin-text@0.0.8.js",
      "resources/elements/menu-button.js",
      "resources/elements/progress-bar.html!github:systemjs/plugin-text@0.0.8.js",
      "resources/elements/progress-bar.js",
      "resources/index.js",
      "resources/value-converters/date-format.js",
      "resources/value-converters/groupBy.js",
      "resources/value-converters/sort.js",
      "settings/app-level/app-settings.html!github:systemjs/plugin-text@0.0.8.js",
      "settings/app-level/app-settings.js",
      "settings/app-level/handlers.html!github:systemjs/plugin-text@0.0.8.js",
      "settings/app-level/handlers.js",
      "settings/app-level/new-handler.html!github:systemjs/plugin-text@0.0.8.js",
      "settings/app-level/new-handler.js",
      "settings/global-settings.html!github:systemjs/plugin-text@0.0.8.js",
      "settings/index.js",
      "settings/member-level/member-settings.html!github:systemjs/plugin-text@0.0.8.js",
      "settings/member-level/member-settings.js",
      "settings/member-settings.html!github:systemjs/plugin-text@0.0.8.js",
      "settings/member-store.js",
      "settings/settings-store.js",
      "shell/handler-menu.html!github:systemjs/plugin-text@0.0.8.js",
      "shell/handler-menu.js",
      "shell/nav-bar.html!github:systemjs/plugin-text@0.0.8.js",
      "shell/request-menu.html!github:systemjs/plugin-text@0.0.8.js",
      "shell/request-menu.js",
      "shell/search-bar-service.js",
      "shell/search-bar.html!github:systemjs/plugin-text@0.0.8.js",
      "shell/search-bar.js",
      "shell/settings-menu.html!github:systemjs/plugin-text@0.0.8.js",
      "shell/settings-menu.js",
      "utils.js"
    ]
  },
  depCache: {
    "app.js": [
      "./configuration/http-client",
      "./configuration/router",
      "aurelia-framework",
      "aurelia-event-aggregator",
      "aurelia-router"
    ],
    "assignments/assignment-store.js": [
      "aurelia-framework",
      "../core/resource-store"
    ],
    "assignments/handler-list.js": [
      "../settings/member-store",
      "aurelia-framework"
    ],
    "assignments/notes.js": [
      "../settings/member-store",
      "./assignment-store",
      "aurelia-framework",
      "jquery"
    ],
    "assignments/priority-flags.js": [
      "../settings/settings-store",
      "aurelia-framework"
    ],
    "configuration/http-client.js": [
      "aurelia-fetch-client",
      "aurelia-framework"
    ],
    "configuration/router.js": [
      "../settings/settings-store",
      "aurelia-framework",
      "aurelia-router"
    ],
    "configuration/toastr.js": [
      "toastr"
    ],
    "constants.js": [
      "keymirror"
    ],
    "core/http-interceptors.js": [
      "aurelia-validation",
      "../core/logger",
      "aurelia-framework"
    ],
    "core/logger.js": [
      "toastr"
    ],
    "core/resource-store.js": [
      "aurelia-fetch-client",
      "aurelia-framework",
      "fetch"
    ],
    "core/store.js": [
      "aurelia-event-aggregator",
      "aurelia-framework"
    ],
    "main.js": [
      "./core/http-interceptors",
      "aurelia-framework",
      "./core/logger.js",
      "bootstrap",
      "./configuration/toastr"
    ],
    "register.js": [
      "./core/http-interceptors",
      "bootstrap",
      "./configuration/toastr"
    ],
    "registration.js": [
      "aurelia-framework",
      "aurelia-event-aggregator",
      "./constants",
      "./configuration/http-client",
      "./settings/settings-store",
      "aurelia-pal"
    ],
    "requests/comment-store.js": [
      "../core/logger",
      "../core/resource-store",
      "aurelia-fetch-client",
      "aurelia-framework"
    ],
    "requests/comments.js": [
      "./comment-store",
      "../settings/member-store",
      "aurelia-framework"
    ],
    "requests/new-request.js": [
      "aurelia-dialog",
      "./request-store",
      "aurelia-framework",
      "aurelia-validation"
    ],
    "requests/request-detail.js": [
      "jquery",
      "./request-store",
      "aurelia-framework"
    ],
    "requests/request-list.js": [
      "./request-store",
      "../shell/search-bar-service",
      "../resources/dialogs/validation-list",
      "aurelia-framework",
      "aurelia-validation",
      "aurelia-dialog",
      "aurelia-event-aggregator",
      "../constants"
    ],
    "requests/request-store.js": [
      "aurelia-framework",
      "../core/resource-store",
      "../core/attachment-service",
      "aurelia-fetch-client",
      "../core/logger",
      "aurelia-event-aggregator",
      "../core/store",
      "../constants"
    ],
    "requests/request.js": [
      "aurelia-framework",
      "moment"
    ],
    "requests/status-list.js": [
      "../settings/settings-store",
      "../settings/member-store",
      "aurelia-framework"
    ],
    "requests/view-list.js": [
      "shell/search-bar-service",
      "../settings/member-store",
      "aurelia-framework"
    ],
    "resources/dialogs/validation-list.js": [
      "aurelia-dialog",
      "aurelia-framework",
      "aurelia-validation"
    ],
    "resources/elements/badge-list.js": [
      "aurelia-framework"
    ],
    "resources/elements/color-flag.js": [
      "aurelia-framework"
    ],
    "resources/elements/date-picker.js": [
      "jquery",
      "moment",
      "aurelia-framework",
      "jquery-ui"
    ],
    "resources/elements/menu-button.js": [
      "aurelia-framework"
    ],
    "resources/elements/progress-bar.js": [
      "aurelia-framework"
    ],
    "resources/value-converters/date-format.js": [
      "moment"
    ],
    "resources/value-converters/sort.js": [
      "../../utils.js",
      "moment"
    ],
    "settings/app-level/app-settings.js": [
      "aurelia-framework",
      "aurelia-event-aggregator",
      "../../constants",
      "../settings-store"
    ],
    "settings/app-level/handlers.js": [
      "../member-store",
      "aurelia-framework"
    ],
    "settings/app-level/new-handler.js": [
      "aurelia-dialog",
      "../member-store",
      "aurelia-framework",
      "aurelia-validation"
    ],
    "settings/index.js": [
      "./member-store",
      "aurelia-framework"
    ],
    "settings/member-level/member-settings.js": [
      "aurelia-framework",
      "../member-store"
    ],
    "settings/member-store.js": [
      "aurelia-fetch-client",
      "aurelia-framework",
      "../core/logger",
      "../core/resource-store",
      "../core/store",
      "../constants",
      "aurelia-event-aggregator"
    ],
    "settings/settings-store.js": [
      "../core/resource-store",
      "aurelia-framework",
      "aurelia-fetch-client",
      "../core/logger",
      "aurelia-event-aggregator",
      "../core/store",
      "../constants"
    ],
    "shell/handler-menu.js": [
      "aurelia-dialog",
      "../settings/app-level/new-handler",
      "../settings/member-store",
      "aurelia-framework"
    ],
    "shell/request-menu.js": [
      "aurelia-dialog",
      "../requests/new-request",
      "aurelia-framework"
    ],
    "shell/search-bar.js": [
      "shell/search-bar-service",
      "aurelia-framework"
    ],
    "shell/settings-menu.js": [
      "../settings/member-store",
      "../settings/settings-store",
      "aurelia-framework"
    ],
    "utils.js": [
      "moment"
    ]
  }
});

太棒了,我很高兴它有效!

仅供遇到相同问题的其他人的功能参考:

尝试将此添加到 HTML <base href="/vd1/vd2/"> 的头部,这将解决问题。

或将<base href="@Url.Content("~/")" />添加到_Layout.cshtml,让asp.net为您生成此路径。