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

@hlw-uni-mp/vite-plugin

v1.0.21

Published

HLW Vite Plugin for auto app environment variables and type definitions

Readme

@hlw-uni-mp/vite-plugin

基于 Vite 与 Uni-App 的工程增强开发插件,专为 HLW 前端生态设计。集成环境变量自动注入、Easycom 组件规则挂载、v-copy 编译期指令转换与声明文件自动生成。


核心特性

  • 环境变量与宏定义自动注入:按运行模式动态解析 .env 与 .env.[mode],自动挂载 __APP_VERSION_NAME__、__APP_BASE_URL__ 等全局常量。
  • 类型声明自动生成:启动/构建时自动生成 src/types/host-env.d.ts,赋予 import.meta.env 与全局宏完整的 TypeScript 类型提示。
  • Easycom 自动挂载:内置 ^hlw-(.*) 组件匹配规则,无需在 pages.json 手动配置即可在模板中直接使用 @hlw-uni-mp/vue UI 组件。
  • v-copy 编译期转换:模板中的 v-copy="text" 指令在编译期自动转换为原生 @tap 与系统剪贴板调用,100% 零运行时侵入与体积开销。
  • UnoCSS 极简门面模式:导出 hlwUnoConfig,开箱自带微信小程序全套原子预设、字号变量、色彩体系、全局 .container 与常用图标 Safelist,业务项目 2 行代码即可接入并支持深度覆盖。
  • 极速轻量:纯净无外部冗余依赖,构建打包秒级完成。

安装

# pnpm
pnpm add -D @hlw-uni-mp/vite-plugin

# npm
npm install -D @hlw-uni-mp/vite-plugin

快速使用

在 vite.config.ts 中引入并挂载 hlwPlugin:

import { defineConfig } from "vite";
import uni from "@dcloudio/vite-plugin-uni";
import { hlwPlugin } from "@hlw-uni-mp/vite-plugin";

export default defineConfig({
    plugins: [
        hlwPlugin({
            autoImport: false, // 是否开启常用 API 自动导入
        }),
        uni(),
    ],
});

UnoCSS 极简配置使用 (unocss.config.ts)

在项目根目录创建 unocss.config.ts,只需调用 hlwUnoConfig:

import { hlwUnoConfig } from "@hlw-uni-mp/vite-plugin";

// 零配置即可享受全套默认规则;如有项目专属定制,直接传入对象即可深度覆盖:
export default hlwUnoConfig({
    // shortcuts: [
    //     ["container", "relative z-10 flex flex-col w-full mx-auto p-4 gap-4 text-slate-900"], // 同名直接覆盖默认
    // ],
    // theme: {
    //     colors: { primary: { DEFAULT: "#059669" } }, // 深度合并覆盖颜色
    // },
});

配置项 (PluginOptions)

| 参数 | 类型 | 默认值 | 说明 | | :--- | :--- | :--- | :--- | | cwd | string | process.cwd() | 运行根目录 | | base | string | env.VITE_BASE_URL | 覆盖基础服务端地址 | | wss | string | env.VITE_WSS_URL | 覆盖 WebSocket 服务端地址 | | dts | string | 'src/types/host-env.d.ts' | 环境变量类型声明文件生成路径 | | autoImport | boolean | false | 是否开启自动导入 | | autoImportDts | string | - | 自动导入类型声明文件路径 | | easycomReplacement | string | - | 自定义 Easycom 组件解析路径映射 | | dropConsole | boolean | mode === 'production' | 生产构建时自动清除 console.log 等调试日志 |


注入的全局宏定义

插件会自动解析注入以下全局编译期常量(可在代码中直接使用):

__APP_VERSION_CODE__  // 数字版本号,例如: 10100
__APP_VERSION_NAME__  // 字符串版本,例如: "1.1.0"
__APP_BASE_URL__      // 接口基地址,例如: "https://api.example.com"
__APP_WSS_URL__       // 通讯地址,例如: "wss://api.example.com/ws"
__APP_NAME__          // 应用名称
__APPID__             // 小程序 AppID
__HLW_ENV__           // 完整环境变量键值对象

License

MIT