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

@alwing/vite-plugin-uni-resource-helper

v1.0.7

Published

自动生成静态资源引用

Downloads

9

Readme

@alwing/vite-plugin-uni-resource-helper

  • uniapp cli项目 vite插件

    vue页面模版中通过asserts.xxx访问静态资源,访问静态资源时自动补全路径

  • 安装

    npm install @alwing/vite-plugin-uni-resource-helper
  • vite环境变量初始化​

    项目更目录下新建env目录

    env目录下新建.env.development.env.production

    # 微信小程序环境下,static目录会被打包到本地,容易超2M的限制
    # 因此微信小程序环境,可以将静态资源打包放到服务器,此处就可以设置静态资源的服务器前缀
    VITE_FTP_URL = `http://127.0.0.1:8849/base_pro/images`
      
    # 静态资源/ftp前缀
    VITE_FTP_URL = `/static/images`

    vite.config.js中配置envDir

    export default ({ command, mode }) => {
    	return defineConfig({
    	  envDir: "./env",
    	  plugins: [
    		  uni()
    	  ]
    	})
    }
  • vite.config.js中导入

    import uni from '@dcloudio/vite-plugin-uni'
    import uniResourceHelper from "@alwing/vite-plugin-uni-resource-helper";
      
    export default ({ command, mode }) => {
    	return defineConfig({
    	  envDir: "./env",
    	  plugins: [
    		  uni(),
          uniResourceHelper({
    			  dts: "./src/asserts.d.ts",            //.d.ts生成路径
            // inputDir: "./src/static/images"    //静态资源存放路径
    			  inputDir: "./images"       //静态资源存放路径
    		  })
    	  ]
    	})
    }	
  • 页面中使用

    main.js引入(VUE3)

    import { createSSRApp } from "vue";
    import App from "./App.vue";
    import { ASSERTS } from "virtual:resource-helper";
      
    export function createApp() {
      const app = createSSRApp(App); 
      app.config.globalProperties["asserts"] = ASSERTS;
      return { 
        app,
      };
    }

    页面中使用

    <template>
      <view class="content">
        <image class="logo" :src="asserts?.ic_tab_todo" />
      </view>
    </template>

    模版中敲asserts.代码自动提示配置

    修改shims-uni.d.ts

    /// <reference types='@dcloudio/types' />
    import 'vue'
      
    declare module '@vue/runtime-core' {
      type Hooks = App.AppInstance & Page.PageInstance;
      
      interface ComponentCustomOptions extends Hooks {
      
      }
        
      interface ComponentCustomProperties extends Hooks {
      	asserts?: ImageResource
      }
    }

    修改src/shims-uni.d.ts

    export {}
      
    declare module "vue" {
      type Hooks = App.AppInstance & Page.PageInstance;
      interface ComponentCustomOptions extends Hooks { 
      	  
      }
      interface ComponentCustomProperties extends Hooks {
      	asserts?: ImageResource
      }
    }