@evila/vue-auto-routes

A hack way to auto generate vue routes

This package has been move to `vue-auto-routes`
Last updated 2 years ago by evila .
WTFPL · Repository · Bugs · Original npm · Tarball · package.json
$ cnpm install @evila/vue-auto-routes 
SYNC missed versions from official npm registry.

vue-auto-routes

A hack way to auto generate vue routes.

Notice ️⚡️

Install

npm install --save @evila/vue-auto-routes

Usage

// example directory
|- src/
|--- pages/
    |--- foo/
    |   |- index.vue
    |--- _id.vue // dynamicRoute, same with folder
    |--- index.vue
|- webpack.config.js

// webpack.config.js
const VueAutoRoutes = require('@evila/vue-auto-routes/lib/plugin')

module.exports = {
  plugins: [
    new VueAutoRoutes({
      pages: require('path').resolve(__dirname, './src/pages')
    })
  ]
}

// router.js
import routes from '@evila/vue-auto-routes'

export default new Router({ routes })

console.log(routes) // Check about it!

Params

new VueAutoRoutes([options<object>])

options

pages

  • Type: String
  • Required: true

Pages directory, recommand to use path module

ignore

  • Type: Array<String>
  • Default: []

Ignore some directory you don't wanna include into routes under pages directory

e.g. ['**/src/components']

extensions

  • Type: Array<String>
  • Default: ['vue']

All .vue files will auto join vue-routes under pages directory (same with ['vue', 'js'])

importPrefix

  • Type: String
  • Default: '@/pages'

Depend on config.resolve.alias['@']

import component from '@/pages/component.vue'

dynamicImport

  • Type: Boolean
  • Default: false

If set true, please make sure is using babel and babel-plugin-syntax-dynamic-import in project

const component = () => import('@/pages/component.vue')

webpackChunkName

  • Type: String
  • Default: ''

Make sure already set dynamicImport is true

{ webpackChunkName: 'myRoutes' }

const component = () => import(/* webpackChunkName: 'myRoutes' */ '@/pages/component.vue')

env

  • Type: String
  • Default: 'NODE_ENV'

This is an un-friendly option.

Work well in development mode

But when you build to production version still need you set a filed is production in command line.

# example scripts command
cross-env NODE_ENV=production webpack --config webpack.config.js

Will get NODE_ENV value

Current Tags

  • 0.2.0                                ...           latest (2 years ago)

10 Versions

  • 0.2.0 [deprecated]           ...           2 years ago
  • 0.1.10 [deprecated]           ...           2 years ago
  • 0.1.9 [deprecated]           ...           2 years ago
  • 0.1.7 [deprecated]           ...           2 years ago
  • 0.1.6 [deprecated]           ...           2 years ago
  • 0.1.5 [deprecated]           ...           2 years ago
  • 0.1.4 [deprecated]           ...           2 years ago
  • 0.1.3 [deprecated]           ...           2 years ago
  • 0.1.0 [deprecated]           ...           2 years ago
  • 0.0.2 [deprecated]           ...           2 years ago
Maintainers (1)
Downloads
Today 0
This Week 0
This Month 0
Last Day 0
Last Week 1
Last Month 19
Dependencies (3)
Dev Dependencies (0)
None
Dependents (0)
None

Copyright 2014 - 2017 © taobao.org |