npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

vite-plugin-react-umi

v1.0.99

Published

基于umi4的改造,以vite原生插件形式使用

Downloads

5

Readme

基于umi4的改造,以vite原生插件形式使用

执行原理:

UmiApp->getInitialState->access->路由检查权限->执行layout getInitialProps->绘制layout->执行子页面 getInitialProps->绘制子页面

特点支持:


  1. [x] 强大的智能提示,基于umi本地生成缓存文件方案[详情]
  2. [x] 自动导入antd和antd pro样式(暂时不是很完善)[详情]
  3. [x] 配置式路由,支持lazy形式,组件形式,类型形式,组件形式使用[详情]
  4. [x] request
  5. [x] model
  6. [x] access (层级权限,layout和子页面权限有层级关系,还可以单独设置页面跳过)[详情]
  7. [x] appData(访问全局数据) [详情]
  8. [ ] history(基于react-dom-route v6,这玩意跳转有问题直接删掉了)
  9. [x] getInitialProps(单页面预加载数据 sync/async) [详情]
  10. [x] getInitialState(全局预加载数据 sync/async) [详情]
  11. [x] vite原生插件支持
  12. [x] 简单实现全局对象,因为式使用组件形式集成到vite里的,原结构不需要修改 [详情]
  13. [ ] 约定式路由(还没想好咋玩,暂时没加它)

开始使用:

准备:新建一个vite react-ts工程

准备:安装插件 (暂时测试了yarn,别的没测试)

yarn add vite-plugin-react-umi -D

1.修改vite.config.ts

import { defineConfig } from 'vite';
import react from '@vitejs/plugin-react';
import { createUmi } from 'vite-plugin-react-umi';

// https://vitejs.dev/config/
export default defineConfig({
    plugins:[
        react(),
        createUmi({}),
    ],
});

2.新建一个umiConfig.tsx(跟vite.config.ts同目录)

import {defineUmi} from "vite-plugin-react-umi";
import {lazy} from "react";
import One from "./src/one";
import Entry from "./src/Entry";
import Two from "./src/two";

const App = lazy(() => import("./src/App"))

export default defineUmi({
    routes: [
        {
        path:'/',
        element:<Entry />,  //支持导入方式1
        }
        ,{
            path: '/user', 
            element: <App/>,   //支持导入方式3
            access:'test',   //此时所有子路由都需要test权限
            children: [
                {path:"/user",element:"404"},
                {path:"/user/one",element:One,},  //支持导入方式2
                {path:"/user/two",element:<Two />}
            ]
        }
    ]
})

3. 修改tsconfig.json(添加以提供强大的智能提示)

{
  "compilerOptions": {
        "paths": {
        "umi": ["./src/.umi"]
    }
  }
}

4. 修改src/main.tsx(简单的把UmiApp组件放进去就行了,可以设置很多属性)

import React from 'react'
import ReactDOM from 'react-dom'
import {UmiApp} from "umi";
ReactDOM.render(
    <React.StrictMode>
        <UmiApp />
    </React.StrictMode>,
    document.getElementById('root')
)

5.使用vite原生指令运行:vite