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

@pamenv/vite

v1.3.0

Published

Vite plugin: load PAM env into process.env before Vite resolves config

Readme

@pamenv/vite

在 Vite 解析配置之前,把 PAM 环境写进当前进程的 process.env。dev / build 脚本可以继续是普通的 vite,不必再包 pamenv run。

与 @pamenv/next 同构:enabled / dev / ci / oidc。

pnpm add @pamenv/vite pamenv-cli
# 或 npm i @pamenv/vite pamenv-cli
import { defineConfig } from 'vite';
import pamenv from '@pamenv/vite';

export default defineConfig({
  plugins: [
    pamenv({
      slug: 'my-app',
      env: process.env.PAM_ENV ?? 'local',
      oidc: 'github',
      keepEnv: ['APP_ENV'],
      // 默认 PAM 优先;本地临时改 .env / process 测值时用 'local'
      // envPriority: 'local',
      debug: process.env.PAMENV_DEBUG === '1',
      clientPublicPrefixes: ['VITE_']
    })
  ]
});

也可用命名导出:import { createPamenvPlugin } from '@pamenv/vite'。

启用时机

| | 说明 | | --- | --- | | enabled | 总开关。false 永不注入;省略/true 交给自动时机。PAMENV_ENABLED=0 强制关 | | dev | 本地 vite / vite dev(serve)。默认 true | | ci | 匹配 CI 的 vite build。默认:传了 oidc 时为 true | | oidc | 'github' / 'vercel'。仅在对应 CI 生效;本地忽略,仍走 .pam |

自动时机:

  • 本地:仅 serve(除非 dev: false)
  • GITHUB_ACTIONS + oidc: 'github':vite build 注入
  • VERCEL=1 + oidc: 'vercel':vite build 注入

匹配 CI 的 build 默认还会写出密封快照 .pam/deploy-snapshot.json(可用 snapshotPath 覆盖)。纯 SPA 运行时通常不需解封;密钥已在构建期进入 import.meta.env.VITE_*。

本地登录

Token 来自向上查找的最近 .pam(默认 preferLocal: true)。未登录时:

pamenv login --local

GitHub Actions 示例

permissions:
  id-token: write
  contents: read

env:
  PAMENV_BASE_URL: https://pam.qlover.top
  PAM_OIDC_AUD: https://pam.qlover.top
  PAM_ENV: dev

jobs:
  build:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v4
      - run: pnpm install
      - run: pnpm --filter @pamenv/vite run build
      - run: pnpm --filter pamenv-vite-app run build:ci

仓库内示例:apps/pamenv-vite-app;OIDC smoke:.github/workflows/pamenv-github-oidc-smoke.yml。

更多设计见 pamenv docs 与 packages/pamenv/docs/ci-github.md。