Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import Backbone from 'backbone';
- import $ from 'jquery';
- import AppFinder from './app_finder_test';
- export default Backbone.Router.extend({
- routes: {
- '': 'home',
- 'main_app_part': 'mainAppPart',
- '*handleMissingRoute': 'handle404'
- },
- home() {
- $('#app').html("You're on the home page");
- },
- mainAppPart() {
- $('#app').html("You're viewing part of the main app, no async bundle loading here");
- },
- handle404(path) {
- const mini_app_name = AppFinder(path);
- if (mini_app_name) {
- + const handler = require('bundle!./apps/' + mini_app_name + '/index.js');
- - require.ensure([], require => {
- + handler(bundle => {
- - const App = require('./apps/' + mini_app_name + '/index.js').default;
- + const App = bundle.default;
- App();
- Backbone.history.loadUrl();
- });
- } else {
- alert('404');
- }
- },
- });
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement