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

@142vip/cdn

v0.0.1-alpha.0

Published

142vip CDN 静态资源与 URL 工具(media / vip-main JSON + getCdnUrl)

Readme

@142vip/cdn

142vip 图床 npm 包:npm 包内静态资源 + CDN URL 工具,支持 ESM / CJS。

包含 apps/media 图片资源与 apps/vip-main JSON 数据(如 photos.json)。

安装

pnpm add @142vip/cdn

最佳实践

| 场景 | 推荐方式 | | --- | --- | | 前端页面、组件内图片 | import 包内 media 资源,随项目构建与缓存 | | 前端读取照片墙 JSON | import @142vip/cdn/vip-main/photos.json | | 需要统一资源 key、类型提示 | MEDIA_SRC / VIP_MAIN_SRC | | 线上文档、邮件、API 返回 JSON CDN 链接 | VIP_MAIN_CDNgetVipMainProductionCdnUrl | | 线上文档、邮件、API 返回图片 CDN 链接 | getProductionCdnUrl(main + Statically) | | 联调 next 分支未发布资源 | getDevelopmentCdnUrl(next + Statically) | | 切换 CDN 域名或分支 | getCdnUrl(path, { host, branch }) |

优先 import,其次 CDN 外链。 前端项目应尽量走 npm 包静态资源,减少对外部 CDN 的运行时依赖。

前端:import 资源

<script setup lang="ts">
import githubIcon from '@142vip/cdn/media/svg/github.svg'
import wechatCode from '@142vip/cdn/media/wechat/chu-fan-code.jpg'
</script>

<template>
  <img :src="githubIcon" alt="GitHub">
  <img :src="wechatCode" alt="微信公众号">
</template>

类型安全的资源 key

MEDIA_SRC 由仓库 apps/media 同步生成:

import { MEDIA_SRC } from '@142vip/cdn'

const githubPath = MEDIA_SRC.svg.github
// '@142vip/cdn/media/svg/github.svg' — 供 bundler 解析或动态 import

vip-main JSON(photos.json)

VIP_MAIN_SRC / VIP_MAIN_CDN 由仓库 apps/vip-main 同步生成:

import type { LifePhotoItem } from '@142vip/cdn'
import {
  getVipMainProductionCdnUrl,
  VIP_MAIN_CDN,
  VIP_MAIN_SRC,
} from '@142vip/cdn'
import photos from '@142vip/cdn/vip-main/photos.json'

const items = photos as LifePhotoItem[]

// 包内 import 路径
const photosExport = VIP_MAIN_SRC.photos
// '@142vip/cdn/vip-main/photos.json'

// CDN 外链
const prodUrl = VIP_MAIN_CDN.photos.production
// 或
const prodUrl2 = getVipMainProductionCdnUrl('photos.json')

CDN 外链

路径相对于 apps/,不含 apps/ 前缀:

import {
  getCdnUrl,
  getDevelopmentCdnUrl,
  getProductionCdnUrl,
} from '@142vip/cdn'

const prodUrl = getProductionCdnUrl('media/svg/github.svg')
const devUrl = getDevelopmentCdnUrl('media/wechat/chu-fan-code.jpg')
const customUrl = getCdnUrl('media/svg/github.svg', {
  host: 'cdn.jsdelivr.net',
  branch: 'main',
})

Node.js(ESM / CJS)

import { getProductionCdnUrl, MEDIA_SRC } from '@142vip/cdn'

export const avatarUrl = getProductionCdnUrl('media/wechat/chu-fan-code.jpg')
export const githubExport = MEDIA_SRC.svg.github
const { getProductionCdnUrl } = require('@142vip/cdn')

module.exports.wechatUrl = getProductionCdnUrl('media/wechat/chu-fan-code.jpg')

API

| 导出 | 说明 | | --- | --- | | MEDIA_SRC / MediaSrc | media 资源路径映射 | | VIP_MAIN_SRC / VipMainSrc | vip-main JSON 包内路径映射 | | VIP_MAIN_CDN / VipMainCdn | vip-main JSON CDN 链接(production / development) | | mediaExportPath(path) | 构造 media 包内 export 路径 | | vipMainExportPath(path) | 构造 vip-main JSON 包内 export 路径 | | getVipMainCdnUrl(path, options?) | vip-main JSON CDN URL | | getVipMainProductionCdnUrl(path, host?) | vip-main JSON 生产环境 CDN URL | | getVipMainDevelopmentCdnUrl(path, host?) | vip-main JSON 开发环境 CDN URL | | LifePhotoItem | photos.json 单条数据类型 | | getCdnBase(options?) | CDN apps 根 URL | | getCdnUrl(path, options?) | 完整 CDN 文件 URL | | getProductionCdnUrl(path, host?) | 生产环境(main) | | getDevelopmentCdnUrl(path, host?) | 开发环境(next) | | getDefaultCdnHost() | 默认 Statically | | getDefaultCdnBranch() | 默认 next | | getCdnDomains() | 可选 CDN 域名列表 |

本仓库维护

在 monorepo 根目录:pnpm sync:cdn · pnpm build:cdn · pnpm prepublish:cdn · pnpm publish:cdn

新增 CDN 域名:编辑 src/config.tsdomains 数组。

证书

MIT © 2019-present 142vip 储凡