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

@xbsheng/umi-plugin-env

v1.0.1

Published

Umi插件,用于基于环境变量加载不同的.env文件

Readme

umi-plugin-env

CI npm version npm downloads

一个用于在 Umi 项目中基于环境变量加载不同环境配置文件的插件。

安装

# 推荐使用 pnpm
pnpm add @xbsheng/umi-plugin-env -D

# 或者使用 npm
npm install @xbsheng/umi-plugin-env --save-dev

# 或者使用 yarn
yarn add @xbsheng/umi-plugin-env --dev

配置

在你的 Umi 配置中(.umirc.ts 或 config/config.ts)启用此插件:

export default {
  plugins: ['@xbsheng/umi-plugin-env'],
  env: {
    // 可选:自定义环境变量键名(默认为 UMI_ENV)
    envKey: 'MY_CUSTOM_ENV',
  },
}

使用方法

  1. 创建对应环境的配置文件,例如:.env.dev.env.test.env.prod

  2. 运行 Umi 应用时设置环境变量:

# 使用默认环境变量键 UMI_ENV
UMI_ENV=dev umi dev

# 或者使用自定义环境变量键
MY_CUSTOM_ENV=prod umi build

该插件会自动加载对应的环境文件(例如:.env.dev)中的环境变量到 process.env 中。

示例

.env.dev 文件内容:

UMI_APP_API_URL=https://dev-api.example.com
UMI_APP_ENABLE_MOCK=true

.env.prod 文件内容:

UMI_APP_API_URL=https://api.example.com
UMI_APP_ENABLE_MOCK=false

在应用中使用:

// 根据运行环境自动获取不同的API URL
const apiUrl = process.env.UMI_APP_API_URL

特性

  • 支持多环境配置
  • 自定义环境变量键名
  • 环境变量优先级:命令行 > .env.[env] > 已存在的环境变量

开发

本项目使用以下工具:

# 安装依赖
pnpm install

# 构建
pnpm run build

# 运行测试
pnpm test

# 检查代码规范
pnpm run lint

# 格式化代码
pnpm run format

# 自动修复 ESLint 错误
pnpm run lint:fix

许可证

MIT