# router-cut-loader

> a webpack loader simplifying router config to shorten bundle time.

Latest version **1.1.8** (published 2018-10-25) · ISC license · 0 weekly downloads

## Install

```sh
npm install router-cut-loader
pnpm add router-cut-loader
yarn add router-cut-loader
bun add router-cut-loader
```

## Health

**Score 15/100 (F)** — status: abandoned.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.1.8 |
| Published | 2018-10-25 |
| First published | 2018-09-30 |
| Weekly downloads | 0 |
| License | ISC |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 1 |
| Unpacked size | 6.2 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 2 |
| Author | lichao |
| Maintainers | lichao.franklee |
| Keywords | webpack, loader, vue-router |

## Links

- npm: https://www.npmjs.com/package/router-cut-loader
- Repository: https://github.com/lichao0202/router-cut-loader
- Issues: https://github.com/lichao0202/router-cut-loader/issues
- npm.io page: https://npm.io/package/router-cut-loader

## Dependencies (1)

- [loader-utils](https://npm.io/package/loader-utils.md) ^1.1.0

## Alternatives

- [express-promise-router](https://npm.io/package/express-promise-router.md) — 736.1K weekly downloads
- [next-usequerystate](https://npm.io/package/next-usequerystate.md) — 29.8K weekly downloads
- [@bitkyc08/opencodex](https://npm.io/package/@bitkyc08/opencodex.md) — 4.6K weekly downloads
- [lynkr](https://npm.io/package/lynkr.md) — 575 weekly downloads
- [baremetal.js](https://npm.io/package/baremetal.js.md) — 42 weekly downloads

## Recent versions

- 1.1.8 (latest) — 2018-10-25
- 1.0.7-beta (beta) — 2018-10-15
- 1.1.7 — 2018-10-16
- 1.0.6-beta — 2018-10-15
- 1.0.6 — 2018-10-11
- 1.0.5 — 2018-10-07
- 1.0.4 — 2018-10-03
- 1.0.3 — 2018-09-30
- 1.0.2 — 2018-09-30
- 1.0.1 — 2018-09-30
- 1.0.0 — 2018-09-30

## README

## Aim of the loader
Let's say we have a vue project with router configuration bellow:
```js
  [
    {
      path: '/module_1/page_1',
      component: component_11
    },
    {
      path: '/module_1/page_2',
      component: component_12
    },
    ...
    {
      path: '/module_1/page_n',
      component: component_1n
    },
    {
      path: '/module_2/page_1',
      component: component_21
    }
    {
      path: '/module_2/page_2',
      component: component_22
    },
    ...
    {
      path: '/module_2/page_n',
      component: component_2n
    }
  ]
```
We are now working on 'module_1', but every time we want to rebuild the project in development, we have to rebulid the 'module_2' as well, which wastes a lot of time. So we want to eliminate modules we don't care right now in development. This loader can help you with loader options bellow:
```js
  options: {
    all: false,
    include: [
      'module_1'
    ]
  }
```
With the configuation, the loader will keep the router object whose path starts with 'module_1', and delete the rest . Obviously, the lesser router object, the shorter time cost in building.


## install

`
  npm install --save-dev router-cut-loader
`

## Usage
webpack.config.js

``` js
module.exports = {
  module: {
    rules: [
      {
        test: /file\/to\/process/,
        loader: 'router-cut-loader',
        options: {
          all: false, // false or true
          include: [
            // first word in router path
            // ex: { path: '/detail/:id', component: '...' }
            // if you want to load this component, you should have "detail" written here
          ]
        }
      }
    ]
  }
}
```
## options

name|type|default|description
:---:|:--:|:---:|:---
all|Boolean|true|load all router components or not, if set to true, the include config below will be ignored.
include|Array of string|[]|the item of the array is the first word of router path, if all is set to true, this will be ignored.
printPath|String|''|Absolute path to print out the router configuration after shifting, file name must be contained in the path. Not required.
showTimeCost|Boolean|false|Print out milliseconds the loader cost. Not required.

## notice

1. Be aware that this loader is only aimed at improving development efficiency, so use this loader only in development environment.

---
_Source: https://npm.io/package/router-cut-loader · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
