1.1.0 • Published 3 years ago

vite-plugin-generate-routes v1.1.0

Weekly downloads
-
License
MIT
Repository
github
Last release
3 years ago

vite-plugin-generate-routes

auto watch page's change and generate routes

use

/** vite.config.js */
import pluginRoutes from 'vite-plugin-generate-routes'
export default defineConfig({
  plugins: [
    pluginRoutes()
  ]
  ...
}

nuxt rules

pages:
--| page1.vue
--| id.vue
--| page2
----| index.vue
----| page21.vue
----| _id_.vue
--| page3
----| page31.vue
----| #componentName.vue

=>

routes:
--| page1
--| page2
----| page2/page21
----| page2/:id
----| page31
  • start with '_' means dynamic component:page/_id.vue => /page/:id
  • start width '#' means ignore

config

dir

  • Type: string
  • Default: src/views

extend

  • Type: Function
export default defineConfig({
  plugins: [
    pluginRoutes({
      extend: (route) => {
        if(route.path === '/') {
          route = {
            title: 'root'
            meta: {
              auth: false
            },
            ...route
          }
        }
      }
    })
  ]
  ...
}
1.1.0

3 years ago

1.0.9

3 years ago

1.0.8

3 years ago

1.0.7

3 years ago

1.0.6

3 years ago

1.0.5

3 years ago

1.0.4

3 years ago

1.0.3

3 years ago

1.0.2

3 years ago

1.0.1

3 years ago

1.0.0

3 years ago