No More Posting New Topics!

If you have a question or an issue, please start a thread in our Github Discussions Forum.
This forum is closed for new threads/ topics.

Navigation

    Quasar Framework

    • Login
    • Search
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Groups
    • Search

    Split my routes.js

    Help
    2
    3
    182
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • PeterQF
      PeterQF last edited by

      Hi guys,

      I’m trying to split my routes.js file into several files for structure purpose.

      Any tip on how to do this?

      Something like this:

      const routes = [
        {
          path: '/',
          component: () => import('layouts/Default.vue'),
          children: [
              require('./allroutes/routegroup1.js'),
              require('./allroutes/routegroup2.js'),
              require('./allroutes/routegroup3.js')
          ]
        }
      ]
      
      // Always leave this as last one
      if (process.env.MODE !== 'ssr') {
        routes.push({
          path: '*',
          component: () => import('pages/Error404.vue')
        })
      }
      
      export default routes
      

      Thank you.

      1 Reply Last reply Reply Quote 0
      • s.molinari
        s.molinari last edited by

        You’d need to import them. There is a couple of ways to do it. This repo shows a modular way and by concatenating the route definitions together.

        https://github.com/disjfa/kazoo

        Scott

        1 Reply Last reply Reply Quote 1
        • PeterQF
          PeterQF last edited by

          @s-molinari , thank you so much 🙂

          1 Reply Last reply Reply Quote 0
          • First post
            Last post