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-uni-virtual-host

v0.0.2

Published

自动为 uni-app 组件注入 `virtualHost: true` 配置,让微信小程序的组件行为与 App/H5 端保持一致

Readme

vite-plugin-uni-virtual-host

自动为 uni-app 组件注入 virtualHost: true 配置,让微信小程序的组件行为与 App/H5 端保持一致。

为什么需要这个插件?

在 uni-app 多端开发中,微信小程序的组件会多一层虚拟节点,导致样式和属性透传行为与 App/H5 端不一致。通过给组件配置 virtualHost: true,可以让小程序组件表现更接近标准 Vue 组件:

  • ✅ 支持父组件样式透传到子组件根元素
  • ✅ 支持 classstyleid 等属性透传
  • ✅ 减少跨端开发的心智负担

详细背景请参考:uni-app 多端组件属性与样式透传行为一致性实践

安装

pnpm add -D vite-plugin-uni-virtual-host

使用

vite.config.ts 中引入插件(建议配合 mergeVirtualHostAttributes 选项使用):

import fs from 'node:fs'

import { parseJson } from '@dcloudio/uni-cli-shared'
import uni from '@dcloudio/vite-plugin-uni'
import { defineConfig } from 'vite'
// @ts-nocheck
import uniVirtualHost from 'vite-plugin-uni-virtual-host'

const uniPlugin = uni() as any

const isEnabled = process.env.UNI_PLATFORM === 'mp-weixin'
  && parseJson(fs.readFileSync('./src/manifest.json', 'utf-8'), false, './src/manifest.json')['mp-weixin']
    .mergeVirtualHostAttributes

export default defineConfig({
  plugins: [
    uniPlugin,
    isEnabled && uniVirtualHost(),
  ].filter(Boolean),
})

插件会自动为所有组件(页面和 App.vue 除外)注入以下配置:

defineOptions({
  options: {
    virtualHost: true
  }
})

配置

忽略特定组件

默认会跳过 App.vueApp.ku.vuepages.json 中的页面。如需排除其他目录(如 uni_modules),可配置 ignore 选项:

uniVirtualHost({
  ignore: [
    'App.vue',
    'App.ku.vue',
    '**/uni_modules/**', // 忽略 uni_modules 目录
  ],
})

支持 glob 语法:***?,路径分隔符统一使用 /

License

MIT