Search code examples
iisasp.net-corevirtual-directoryaurelia

Aurelia bundling issue with virtual directory


UPDATE

I found the source of the problem, but i still can't figure it out. Everything loads correctly if the site is http://mysite/vd1/vd2/ and not http://mysite/vd1/vd2 (the correct one has the trailing slash)

Original

I am attempting to publish my first aspnetcore aurelia-app to IIS in a virtual directory http://mysite/vd1/vd2 where vd2 (virtual directory2) is the home of the aurelia-app. However when the browser tries to load the first bundle, aurelia.js, it is looking in the http://mysite/vd1/dist instead of vd2, which returns a 404. I have tried to make the paths relative, but maybe I am missing something? Any help is appreciated and please let me know if more information is needed because i am having problems tracking down the problem.

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/[email protected]/js/browser/bluebird.js"></script>
  </environment>
  <environment names="Staging,Production">
    <script src="~/jspm_packages/npm/[email protected]/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:[email protected]",
    "aurelia-bootstrapper": "npm:[email protected]",
    "aurelia-dialog": "npm:[email protected]",
    "aurelia-event-aggregator": "npm:[email protected]",
    "aurelia-fetch-client": "npm:[email protected]",
    ...
  },
  bundles: {
    "aurelia.js": [
      "github:CodeSeven/[email protected]",
      "github:CodeSeven/[email protected]/build/toastr.css!github:systemjs/[email protected]",
      "github:CodeSeven/[email protected]/toastr.js",
      "github:components/[email protected]",
      "github:components/[email protected]/jquery.js",
      "github:components/[email protected]",
      "github:components/[email protected]/jquery-ui.js",
      "github:github/[email protected]",
      "github:github/[email protected]/fetch.js",
      "github:twbs/[email protected]",
      "github:twbs/[email protected]/css/bootstrap.min.css!github:systemjs/[email protected]",
      "github:twbs/[email protected]/js/bootstrap.js",
      "npm:[email protected]",
      "npm:[email protected]/aurelia-animator-css.js",
      "npm:[email protected]",
      "npm:[email protected]/aurelia-binding.js",
      "npm:[email protected]",
      "npm:[email protected]/aurelia-bootstrapper.js",
      "npm:[email protected]",
      "npm:[email protected]/aurelia-dependency-injection.js",
      "npm:[email protected]",
      "npm:[email protected]/ai-dialog-body.js",
      "npm:[email protected]/ai-dialog-footer.js",
      "npm:[email protected]/ai-dialog-header.js",
      "npm:[email protected]/ai-dialog.js",
      "npm:[email protected]/attach-focus.js",
      "npm:[email protected]/aurelia-dialog.js",
      "npm:[email protected]/dialog-configuration.js",
      "npm:[email protected]/dialog-controller.js",
      "npm:[email protected]/dialog-options.js",
      "npm:[email protected]/dialog-renderer.js",
      "npm:[email protected]/dialog-result.js",
      "npm:[email protected]/dialog-service.js",
      "npm:[email protected]/lifecycle.js",
      "npm:[email protected]/renderer.js",
      "npm:[email protected]",
      "npm:[email protected]/aurelia-event-aggregator.js",
      "npm:[email protected]",
      "npm:[email protected]/aurelia-fetch-client.js",
      "npm:[email protected]",
      "npm:[email protected]/aurelia-framework.js",
      "npm:[email protected]",
      "npm:[email protected]/aurelia-history-browser.js",
      "npm:[email protected]",
      "npm:[email protected]/aurelia-history.js",
      "npm:[email protected]",
      "npm:[email protected]/aurelia-loader-default.js",
      "npm:[email protected]",
      "npm:[email protected]/aurelia-loader.js",
      "npm:[email protected]",
      "npm:[email protected]/aurelia-logging-console.js",
      "npm:[email protected]",
      "npm:[email protected]/aurelia-logging.js",
      "npm:[email protected]",
      "npm:[email protected]/aurelia-metadata.js",
      "npm:[email protected]",
      "npm:[email protected]/aurelia-pal-browser.js",
      "npm:[email protected]",
      "npm:[email protected]/aurelia-pal.js",
      "npm:[email protected]",
      "npm:[email protected]/aurelia-path.js",
      "npm:[email protected]",
      "npm:[email protected]/aurelia-polyfills.js",
      "npm:[email protected]",
      "npm:[email protected]/aurelia-route-recognizer.js",
      "npm:[email protected]",
      "npm:[email protected]/aurelia-router.js",
      "npm:[email protected]",
      "npm:[email protected]/aurelia-task-queue.js",
      "npm:[email protected]",
      "npm:[email protected]/aurelia-templating-binding.js",
      "npm:[email protected]",
      "npm:[email protected]/abstract-repeater.js",
      "npm:[email protected]/analyze-view-factory.js",
      "npm:[email protected]/array-repeat-strategy.js",
      "npm:[email protected]/aurelia-hide-style.js",
      "npm:[email protected]/aurelia-templating-resources.js",
      "npm:[email protected]/binding-mode-behaviors.js",
      "npm:[email protected]/binding-signaler.js",
      "npm:[email protected]/compose.js",
      "npm:[email protected]/css-resource.js",
      "npm:[email protected]/debounce-binding-behavior.js",
      "npm:[email protected]/dynamic-element.js",
      "npm:[email protected]/focus.js",
      "npm:[email protected]/hide.js",
      "npm:[email protected]/html-resource-plugin.js",
      "npm:[email protected]/html-sanitizer.js",
      "npm:[email protected]/if.js",
      "npm:[email protected]/map-repeat-strategy.js",
      "npm:[email protected]/null-repeat-strategy.js",
      "npm:[email protected]/number-repeat-strategy.js",
      "npm:[email protected]/repeat-strategy-locator.js",
      "npm:[email protected]/repeat-utilities.js",
      "npm:[email protected]/repeat.js",
      "npm:[email protected]/replaceable.js",
      "npm:[email protected]/sanitize-html.js",
      "npm:[email protected]/set-repeat-strategy.js",
      "npm:[email protected]/show.js",
      "npm:[email protected]/signal-binding-behavior.js",
      "npm:[email protected]/throttle-binding-behavior.js",
      "npm:[email protected]/update-trigger-binding-behavior.js",
      "npm:[email protected]/with.js",
      "npm:[email protected]",
      "npm:[email protected]/aurelia-templating-router.js",
      "npm:[email protected]/route-href.js",
      "npm:[email protected]/route-loader.js",
      "npm:[email protected]/router-view.js",
      "npm:[email protected]",
      "npm:[email protected]/aurelia-templating.js",
      "npm:[email protected]",
      "npm:[email protected]/aurelia-validation.js",
      "npm:[email protected]/implementation/rules.js",
      "npm:[email protected]/implementation/standard-validator.js",
      "npm:[email protected]/implementation/util.js",
      "npm:[email protected]/implementation/validation-messages.js",
      "npm:[email protected]/implementation/validation-parser.js",
      "npm:[email protected]/implementation/validation-rules.js",
      "npm:[email protected]/property-info.js",
      "npm:[email protected]/validate-binding-behavior-base.js",
      "npm:[email protected]/validate-binding-behavior.js",
      "npm:[email protected]/validate-trigger.js",
      "npm:[email protected]/validation-controller-factory.js",
      "npm:[email protected]/validation-controller.js",
      "npm:[email protected]/validation-error.js",
      "npm:[email protected]/validation-errors-custom-attribute.js",
      "npm:[email protected]/validation-renderer-custom-attribute.js",
      "npm:[email protected]/validator.js",
      "npm:[email protected]",
      "npm:[email protected]/dist/jquery.js",
      "npm:[email protected]",
      "npm:[email protected]/index.js",
      "npm:[email protected]",
      "npm:[email protected]/moment.js"
    ],
    "app-build.js": [
      "app.html!github:systemjs/[email protected]",
      "app.js",
      "assignments/assignment-store.js",
      "assignments/handler-list.html!github:systemjs/[email protected]",
      "assignments/handler-list.js",
      "assignments/notes.html!github:systemjs/[email protected]",
      "assignments/notes.js",
      "assignments/priority-flags.html!github:systemjs/[email protected]",
      "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/[email protected]",
      "registration.js",
      "requests/comment-store.js",
      "requests/comments.html!github:systemjs/[email protected]",
      "requests/comments.js",
      "requests/new-request.html!github:systemjs/[email protected]",
      "requests/new-request.js",
      "requests/request-detail.html!github:systemjs/[email protected]",
      "requests/request-detail.js",
      "requests/request-list.html!github:systemjs/[email protected]",
      "requests/request-list.js",
      "requests/request-store.js",
      "requests/request.html!github:systemjs/[email protected]",
      "requests/request.js",
      "requests/status-list.html!github:systemjs/[email protected]",
      "requests/status-list.js",
      "requests/view-list.html!github:systemjs/[email protected]",
      "requests/view-list.js",
      "resources/dialogs/validation-list.html!github:systemjs/[email protected]",
      "resources/dialogs/validation-list.js",
      "resources/elements/attachments.html!github:systemjs/[email protected]",
      "resources/elements/badge-list.html!github:systemjs/[email protected]",
      "resources/elements/badge-list.js",
      "resources/elements/color-flag.html!github:systemjs/[email protected]",
      "resources/elements/color-flag.js",
      "resources/elements/date-picker.html!github:systemjs/[email protected]",
      "resources/elements/date-picker.js",
      "resources/elements/drop-menu.html!github:systemjs/[email protected]",
      "resources/elements/menu-button.html!github:systemjs/[email protected]",
      "resources/elements/menu-button.js",
      "resources/elements/progress-bar.html!github:systemjs/[email protected]",
      "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/[email protected]",
      "settings/app-level/app-settings.js",
      "settings/app-level/handlers.html!github:systemjs/[email protected]",
      "settings/app-level/handlers.js",
      "settings/app-level/new-handler.html!github:systemjs/[email protected]",
      "settings/app-level/new-handler.js",
      "settings/global-settings.html!github:systemjs/[email protected]",
      "settings/index.js",
      "settings/member-level/member-settings.html!github:systemjs/[email protected]",
      "settings/member-level/member-settings.js",
      "settings/member-settings.html!github:systemjs/[email protected]",
      "settings/member-store.js",
      "settings/settings-store.js",
      "shell/handler-menu.html!github:systemjs/[email protected]",
      "shell/handler-menu.js",
      "shell/nav-bar.html!github:systemjs/[email protected]",
      "shell/request-menu.html!github:systemjs/[email protected]",
      "shell/request-menu.js",
      "shell/search-bar-service.js",
      "shell/search-bar.html!github:systemjs/[email protected]",
      "shell/search-bar.js",
      "shell/settings-menu.html!github:systemjs/[email protected]",
      "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"
    ]
  }
});

Solution

  • Wonderful, I am glad it works!

    Just for feature reference of someone else having the same issue:

    Try adding this to the head of the HTML <base href="/vd1/vd2/"> that will resolve the issue.

    Or add <base href="@Url.Content("~/")" /> to _Layout.cshtml to let asp.net generate this path for you.