How can I configure aurelia cli to allow the app to be loaded from a subfolder (a mvc controller vith a view)?
In /MyController/MyView
I have the following code
<div aurelia-app="main" data-module="app2">
<script src="/scripts/vendor-bundle.js" data-main="aurelia-bootstrapper"></script>
</div>
I got an 404 when the loader then tries to load the app-bundle from /MyController/MyView/scripts/app-bundle.js
but it actual location is /scripts/app-bundle.js
Thanks for any help
Larsi
Motivation for question: I'm using Aurelia in an existing asp.net mvc 5 website. We plan to develop new pages as small aurelia apps (one aurelia app per mvc view). We plan on reusing the same bundles on all views (just setting "aurelia.setRoot('nameofapp')" to launch the correct app). This seems to work great when launching at '/' but when lanched from '/MyController/MyView' we need to modify the location the app-bundles are loaded from - and this is what this question is about.
Two things needed to be done:
I figured someone else might need this setup, so I created a repository here: https://github.com/larserikfinholt/aurelia-subfolder
Larsi
In your main.js
aurelia bootstrap file, you can write this:
main.js
configure(aurelia) {
aurelia.use
.standardConfiguration()
.feature('my-app');
}
This will instruct aurelia to load my-app/index.js
as a plugin, exposing the aurelia
object to a configure()
function, just like in the main.js
file. You can do all kinds of fun stuff there, including setting a root view model.
my-app/index.js
configure(aurelia) {
aurelia.start().then(() => aurelia.setRoot('my-app/app.js'));
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With