routes.js 875 B

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  1. import App from "views/App";
  2. const errorLoading = error => {
  3. throw new Error(`Dynamic page loading failed: ${ error }`);
  4. };
  5. const loadRoute = cb => {
  6. return module => cb(null, module.default);
  7. };
  8. export default {
  9. path: "/",
  10. component: App,
  11. indexRoute: {
  12. getComponent(location, cb) {
  13. System.import("views/Home")
  14. .then(loadRoute(cb))
  15. .catch(errorLoading);
  16. },
  17. },
  18. childRoutes: [
  19. {
  20. path: "home",
  21. getComponent(location, cb) {
  22. System.import("views/Home")
  23. .then(loadRoute(cb, false))
  24. .catch(errorLoading);
  25. },
  26. },
  27. {
  28. path: "template",
  29. getComponent(location, cb) {
  30. System.import("views/Template")
  31. .then(loadRoute(cb, false))
  32. .catch(errorLoading);
  33. },
  34. },
  35. {
  36. path: "*",
  37. getComponent(location, cb) {
  38. System.import("views/NotFound")
  39. .then(loadRoute(cb))
  40. .catch(errorLoading);
  41. },
  42. },
  43. ],
  44. };