Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/lijialiang/replace-vue-async-router-babel-plugin


https://github.com/lijialiang/replace-vue-async-router-babel-plugin

Last synced: 8 days ago
JSON representation

Awesome Lists containing this project

README

        

# replace-vue-async-router-babel-plugin

Replace some lazy loaded modules of Vue Router Component with simple functions via the Babel plugin. Reduce Webpack dependencies during development and speed up compilation.

## Install

```sh
npm i replace-vue-async-router-babel-plugin --save-dev

# or

yarn add replace-vue-async-router-babel-plugin --dev
```

## How to use

```js
module: {
rules: [
{
test: /.*\/router\/.*\.js$/,
use: {
loader: 'babel-loader',
options: {
plugins: [
['replace-vue-async-router-babel-plugin', { include: [ '/router/a' ] }]
]
}
}
}
]
}
```

## Example

```js
new VueRouter({
routes: [
{ path: '/a', component: () => import('/router/a.vue') }, // component `a` will be used normally
{ path: '/b', component: () => import('/router/b.vue') }, // component `b` will be replaced
{ path: '/c', component: () => import('/router/c.vue') } // component `c` will be replaced
]
})
```

## LICENSE

[MIT](./LICENSE)