1.0.0 • Published 9 months ago
auto-route-webpack-plugin v1.0.0
auto-route-webpack-plugin
A webpack plugin for automatically injecting route.
Installation
NPM
npm i -D auto-route-webpack-plugin
Yarn
yarn add -D auto-route-webpack-plugin
Import
ES6/TypeScript
import { AutoRoutePlugin } from 'auto-route-webpack-plugin';
CJS
const { AutoRoutePlugin } = require('auto-route-webpack-plugin');
Example with Function
plugins: [
/**
* 指定路由入口文件及目录,自动生成路由列表
* @param {Object} options
* @param {string} options.entry - 需要处理的入口文件,如:auto-route.js
* @param {string} options.routeDir - 路由页所在相对目录,如:scr/view
* @param {string} options.injectAfter - 需要在哪里注入路由信息,如:"routes = " 将被处理为 "routes = [{path: string, name: string, component: () => import(string)}]"
* @param {string} options.suffix - 需要处理的文件后缀,如:".vue"
* @param {string} [options.importPrefix = @] - 动态导入的组件路径前缀,默认值"home"
* @param {string} [options.home = home] - 首页的"name",默认值"home"
*/
new AutoRoutePlugin({
entry: 'auto-route.js',
routeDir: 'src/view',
injectAfter: 'routes =',
suffix: '.txt',
importPrefix: '@/view',
home: 'home',
})
];
1.0.0
9 months ago